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))
                );
Punee
  • 3
  • 3
  • Check this-> http://stackoverflow.com/questions/1162107/display-zend-form-element-radio-on-one-line?rq=1 – Rikesh Sep 10 '12 at 06: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... – Punee Sep 10 '12 at 08:26

1 Answers1

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('  ');
Daya
  • 1,170
  • 10
  • 22
  • 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)) ); – Punee Sep 12 '12 at 07:27
  • 1
    ** public $elementDecoratorsTr = array( 'ViewHelper', 'Description', 'Errors', array('HtmlTag', array('tag' => 'td')) ** Now check it – Daya Sep 12 '12 at 08:43
  • 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? – Daya Sep 12 '12 at 09:40
  • 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.... – Punee Sep 12 '12 at 10:57
  • Hi Daya, I got the solution, just i had added "'disableLoadDefaultDecorators' => true," while adding element radio button. now its working... thank you... – Punee Sep 12 '12 at 12:16