0

Not my idea, but I need a set of radio buttons, where the last buttons value is a select box. Visual explanation:

o Opt 1

o Opt 2

o |___SelectBox|

What it would look like in HTML:

<input type="radio" name="radioSet">Opt1
</input>

<input type="radio" name="radioSet">Opt2
</input>

<input type="radio" name="radioSet"><!-- Opt 3 -->
<select>
<option value="a"> aaa</option>
<option value="b"> bbb</option>
</select>
</input>

What I've done in ZF so far:

$picker = new Zend_Form_Element_Select('selectBox', array(
    'multiOptions' => array('a'=>'aaa', 'b' =>'bbb'),
    'decorators' => array(
        array('Label', array('escape'=>false))
        )
    ));


$this->addElement(
'radio',
'radioSet',
array(
    'multioptions' => array(
            'x'=>'Opt1',
            'y'=>'Opt2',
            'z'=>$picker //'Dropdown picker'
            ),
    'label' => 'My Title:',
    'decorators' => array(
            'ViewHelper',
            'Errors',
            array('Description', array('escape' => false)),
            'Label',
            array('HtmlTag', array('tag'=>'div')),
    ),
)
);

But this returns just the 3 radio buttons, as well as the labels "Opt1" and "Opt2", but nothing after the third radio button.

I WANT it to be like the HTML code shown above, but this ZF code does not return it. Anyone an idea how this can be accomplished?

Thanks!

Nareille
  • 811
  • 2
  • 11
  • 30

2 Answers2

0

unfortunately you probably going to have to write a decorator to replace the label tag with a select. Looking at the code for the Zend_Form_Element_Radio() it specifically adds the label tag to the radio.

RockyFord
  • 8,529
  • 1
  • 15
  • 21
0

Thanks for your advices. I'm quite new to Zend, so I checked up how to make a custom view helper decorator, I couldn't manage to get it to work like that, but it helped me in another problem though.

I came to the solution, that it's easier to just add the select box as an individual element afterwards, and style it to the desired position with css.

Thanks again.

Nareille
  • 811
  • 2
  • 11
  • 30