newhck / php-form-builder-class

Automatically exported from code.google.com/p/php-form-builder-class
GNU General Public License v3.0
0 stars 0 forks source link

Default value for a radio button #199

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
How do you set a default value for for a group of radio buttons?

At present I add a group of radio buttons to a form object in the following way:

$options = array('one'=>"Option #1", 'two'=>"Option #2", 'three'=>"Option #3");
$form->addElement(new Element\Radio("Radio Buttons:", "RadioButtons", $options))

I can't see anything in the documentation that demonstrates a default value.

I'm using version 3.1 and php 5.4

Thanks

Original issue reported on code.google.com by garyburn...@gmail.com on 16 May 2013 at 2:08

GoogleCodeExporter commented 8 years ago
Please try this...

$options = array('one'=>"Option #1", 'two'=>"Option #2", 'three'=>"Option #3");
$form->addElement(new Element\Radio("Radio Buttons:", "RadioButtons", $options, 
array("value" => "one")));

Original comment by ajporterfield@gmail.com on 16 May 2013 at 2:13

GoogleCodeExporter commented 8 years ago
That works.

Thank you.

Original comment by garyburn...@gmail.com on 16 May 2013 at 2:22