Jump to content

Recommended Posts

Hey all, I have a quick question about decorators. I basically want to add a class to the decorator but it doesnt appear to be working:

 

        $input_dec=array(
                   'ViewHelper',
                   'Description',
                   'Errors',
                   array(array('data'=>'HtmlTag'), array('tag' => 'div'), array('class'=>'blue_box')
           );

 

The div appears but it does not have a class. How do I get it to have a class?

 

Also, my form in general seems a bit off due to decorators...

 

    public function init()
    {
        $input_dec=array(
                   'ViewHelper',
                   'Description',
                   'Errors',
                   array(array('data'=>'HtmlTag'), array('tag' => 'div'), array('class'=>'blue_box'), array('id', 'boom_bap')),
           );
        $texarea_dec=array(
                   'ViewHelper',
                   'Description',
                   'Errors',
           );
        ini_set('display_errors',1);error_reporting(E_ALL);
        $this->setName('rsvp_form');
        $name = new Zend_Form_Element_Text('guest_name');
        $name->setAttrib('class', 'rsvp_input click_clear')
            ->setValue('Name')
            ->setDecorators($input_dec);
        $guests = new Zend_Form_Element_Text('number_of_guests');
        $guests->setAttrib('class', 'rsvp_input click_clear')
            ->setValue('# of Guests (including you)')
            ->setDecorators($input_dec);
        $accept=new Zend_Form_Element_Checkbox('accept');
         $options  = array(
            'checkedValue' => '1',
            'uncheckedValue' => '0',
         ); 
        $accept->setOptions($options)
            ->setLabel('Delightfully Accepts')
            ->setAttrib('onclick', 'rsvp_form.attending();');
        $decline=new Zend_Form_Element_Checkbox('decline');
         $options  = array(
            'checkedValue' => '1',
            'uncheckedValue' => '0',
         );
        $decline->setOptions($options)
            ->setLabel('Regretfully Declines')
            ->setAttrib('onclick', 'rsvp_form.attending();');
        $message = new Zend_Form_Element_Textarea('message');
        $message->setValue('Regardless of your attendence, feel free to wish us well! Amy will need it!')
                ->setDecorators($texarea_dec);
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitrsvp');
        $this->addElements(array($name,$guests,$accept,$decline,$message,$submit));
    }

 

Whats happening there is the textarea element is somehow being dispaly in the dd id="decline_element" in IE7. I have no idea why. It works fine in IE8 and FF.

 

When I view source, the html itself seems good, so I dont know why the text area is somehow within the DD

 

<form id="rsvp_form" enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form">
<div>
<input type="text" name="guest_name" id="guest_name" value="Name" class="rsvp_input click_clear"></div>
<div>
<input type="text" name="number_of_guests" id="number_of_guests" value="# of Guests (including you)" class="rsvp_input click_clear"></div>
<dt id="accept-label"><label for="accept" class="optional">Delightfully Accepts</label></dt>
<dd id="accept-element">
<input type="hidden" name="accept" value="0"><input type="checkbox" name="accept" id="accept" value="1" onclick="rsvp_form.attending();"></dd>
<dt id="decline-label"><label for="decline" class="optional">Regretfully Declines</label></dt>
<dd id="decline-element">
<input type="hidden" name="decline" value="0"><input type="checkbox" name="decline" id="decline" value="1" onclick="rsvp_form.attending();"></dd>
<div>
<textarea name="message" id="message" rows="24" cols="80">Regardless of your attendence, feel free to wish us well! Amy will need it!</textarea></div>
<dt id="submit-label"> </dt><dd id="submit-element">
<input type="submit" name="submit" id="submitrsvp" value="Add"></dd></dl></form>    

 

Any ideas as to what is causing it?

 

Amy loves Tony in IE 7

 

Also, how would I go about getting forms into my header? In my layout.phtml I have a header and footer and content sections. I want to be able to draw a form in the header.

 

How would I go about doing this? How does zend framework tackle such a basic issue? Im using this project to learn the concepts behind MVC and zend framework, so sorry if I suck.

 

Would I create a header and footer controller, and then include them somehow by the layout.phtml file?

Link to comment
https://forums.phpfreaks.com/topic/204594-zend-framework-forms-and-decorators/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.