A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearHow can I attach two Radio Buttons in Zend Framework to one ID? - page 1
User InfoPosts
How can I attach two Radio Buttons in Zend Framework to one ID?#1
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.

posted date: 2009-04-13 14:51:00


Re: How can I attach two Radio Buttons in Zend Framework to one ID?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-13 14:51:01


Re: How can I attach two Radio Buttons in Zend Framework to one ID?#3
I changed Zend into Zend Framework. Zend != Zend Framework.

posted date: 2009-04-13 15:18:00


Re: How can I attach two Radio Buttons in Zend Framework to one ID?#4
well ok, please provide the code you(ve written so far! it will be much easier to help then!In general, everything is explained in the Zend_Form manual. I assume you generaly know how to add form elements to a Zend Form. Here you see what options you have for the Radio Button.And this is an example of how it could look like:$gender = new Zend_Form_Element_Radio((gender();$gender->setLabel((Gender:() ->addMultiOptions(array( (male( => (Male(, (female( => (Female( )) ->setSeparator((|();

posted date: 2009-04-13 15:26:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.