Display Zend_Form_Element_Radio on one line
Asked Answered
A

3

16

The radio buttons in Zend Framework are displayed in a column (one option per line). How can I remove the br tag from the markup so that all radio options stay in one line?

My decorators are:

private $radioDecorators = array(
    'Label',
    'ViewHelper',
    array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class' => 'radio')),
    array(array('row' => 'HtmlTag'), array('tag' => 'li')),
);
Ascensive answered 21/7, 2009 at 22:36 Comment(0)
P
51

You need to call the setSeparator method on the Zend_Form_Element_Radio object, passing it ''. Here's an example from here:

<?php     

class CustomForm extends Zend_Form
{
  public function init()
  {
    $this->setMethod('post');
    $this->setAction('user/process');
    $gender = new Zend_Form_Element_Radio('gender');
    $gender->setLabel('Gender:')
      ->addMultiOptions(array(
        'male' => 'Male',
        'female' => 'Female'
      ))
      ->setSeparator('');
  }
}
Pelvic answered 21/7, 2009 at 22:40 Comment(0)
D
3

use options as follows

array("listsep" => ' ')

This will make radio seperation by ' '

Diaphaneity answered 28/8, 2009 at 14:25 Comment(1)
the setSeparator function seems to doesn't take affect yours does. Thanks!Turbit
E
1

Use the Zend_Form_Element_Radio::setSeparator($separator) method:

e.g.

$element->setSeparator('');

The separator defaults to '\<\br />' as shown by getSeparator().

Eleemosynary answered 21/7, 2009 at 22:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.