I have built a form builder, and I need the ability to assign description to every option in a radio element. Upon creation of this radio element, I ask the user to assign each value a description, which should be shown next to the element. So, in my database, I have a value, a title and a description for each option in this radio element.
The question: How do I put something next to a radio element? Do I have to create a new way for the form to render radio elements, or can it be done via decorators?
Any little bit helps, useful reading is welcome too!
A representation of what i need:
**A title of the Radio element**
O Option 1 - A description for option 1
O Option 2 - A description for option 2
O Option 3 - A description for option 3
O Option 4 - A description for option 4
Any ideas?
It's hard to tell from your question but where abouts is the actual radio button in your markup?
If it's to the left or right of the option label, you can simply use the label to enter your extra markup and set the ViewHelper's escape
property to false
to enable HTML
For example
$form->addElement('radio', 'test', array(
'label' => '**A title of the Radio element**',
'multiOptions' => array(
1 => 'Option 1 <strong>- A description for option 1</strong>',
2 => 'Option 2 <strong>- A description for option 2</strong>'
),
'escape' => false
));
Looks like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With