0

while adding this element in to the form the labels are not well decorated. Can anyone help me, that how to decorate radio buttons with label in zend form, i,e how to show labels and radio buttons in a single line...

$this->addElement('radio', 'FORM_EXITS',
                    array('decorators' => $this->elementDecoratorsTr ,'label' => 'Exists :',
                    'multiOptions' => array(
                    '1' => 'Yes',
                    '0' => 'No',
                    ),
                        'Separator' => ''

                ));



 public  $elementDecoratorsTr = array(
                'ViewHelper',
                'Description',
                'Errors',
                array(array('data'=>'HtmlTag'), array('tag' => 'td')),
                //array('ViewScript', array('viewScript' => 'users/adduser.phtml')),
                array('Label', array('tag' => 'td', 'style' => 'float:right;')),
                array(array('row'=>'HtmlTag'), array('tag'=>'tr', 'closeOnly' => true))
                );
2
  • Check this-> stackoverflow.com/questions/1162107/… Commented Sep 10, 2012 at 6:13
  • hi, i am not able to show label as well as radio button in a single line, in my forms, for radio buttons the label appears on top of the form. can anyone help me to display it in a single line. thank you... Commented Sep 10, 2012 at 8:26

1 Answer 1

1
$this->addElement('radio', 'FORM_EXITS',
                array('decorators' => $this->elementDecoratorsTr ,'label' => 'Exists :',
                'multiOptions' => array(
                '1' => 'Yes',
                '0' => 'No',
                ),
                    'Separator' => '   '

            ));

Now test it.

else use the structure like this.

$gender = new Zend_Form_Element_Radio('gender');
$gender->setLabel('Gender:')
       ->setRequired(true)
       ->addMultiOptions(array('male' => 'Male',
                               'female' => 'Female' ))
       ->setSeparator('  ');
Sign up to request clarification or add additional context in comments.

5 Comments

No, still its not working. i am getting same labels two times for radio buttons.this is my decorators code edited :- public $elementDecoratorsTr = array( 'ViewHelper', 'Description', 'Errors', array(array('data'=>'HtmlTag'), array('tag' => 'td')), //array('ViewScript', array('viewScript' => 'users/adduser.phtml')), array(array('label' => 'Label'),array('tag' => 'td', 'style' => 'float:right;')), array(array('row'=>'HtmlTag'), array('tag'=>'tr', 'closeOnly' => true)) );
** public $elementDecoratorsTr = array( 'ViewHelper', 'Description', 'Errors', array('HtmlTag', array('tag' => 'td')) ** Now check it
First of all test without touching Decorators, if you got success in the radio button arrangement then you will apply same Decorators to entire form. and what is the error you got?
No errors, I got success in radio button arrangement also, but only thing is labels of radio buttons are displayed two times, one with decorators and another without decorators. don't know why....
Hi Daya, I got the solution, just i had added "'disableLoadDefaultDecorators' => true," while adding element radio button. now its working... thank you...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.