I am trying to create radio buttons with Zend Framework. This is the way I want to do it:
()Yes ()No John Smith
()Yes ()No Peter Fallon
I want to attach two radio buttons to one ID:
Thanks
Ok now I am getting how this works, thanks for your patience.
Well this is what I have.
class ListForm extends Zend_Form
{
public function __construct() {
parent::__construct();
}
public function createForm(array $model,$checkedArr)
{
// set the method for the display form to POST
$this->setMethod('post');
$this->setAction('/List/inputform');
// add an check box element
$check = new Zend_Form_Element_MultiCheckbox('check');
foreach ($model as $option) {
$check->addMultiOption($option['id'],.$option['name'].' '.$option['lname']);
}
// Add a checkmark to the check box.
$check->setValue($checkedArr);
// add the submit button
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Submit');
$submit->setValue('submit');
return $this->addElements(array($check,$submit));
}}
Then I insert this form into the view
$this->view->form = $form->createForm($model,$array);
By doing this a list of people gets created with a checkbox
[] John Smith
[] Peter Fallon
What I want to do is to change from a checkbox to a two radio buttons, like this
()Yes ()No John Smith
()Yes ()No Peter Fallon
So when the form gets delivered to the Action function on the Controller I can loop trough all the list and determine which one has a Yes selected and which one has a No selected.
I hope that this is more clear.