QuickForm2 - ho
| From: | Alain Williams | Date: | Fri, 20 Nov 2009 12:55:29 +0000 |
| Subject: | QuickForm2 - ho | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-53054@lists.php.net to get a copy of this message | ||
I appear to need to add each 'radio' button one at a time,
can I set them all at once as I can with 'select' where I can do:
$Titles = array('Please select', 'Mr', 'Mrs', 'Miss',
'Dr');
$title = $form->addElement('select', 'Title', null,
array('label' => 'Title', 'options' => $Titles));
.... later on specify default:
$form->addDataSource(new HTML_QuickForm2_DataSource_Array('Title' => 2)));
With a 'radio' I need to go:
$Wdays = array('Mon' => 'Monday', 'Tue' =>
'Tuesday', 'Wed' => 'Wednesday', 'Thu' =>
'Thursday',
'Fri' => 'Friday', 'Sat' => 'Saturday',
'Sun' => 'Sunday');
// Generate a radio button for every day of the week, Tuesday's will be pre set:
foreach($Wdays as $d => $day)
if($d == 'Tue')
$tue = $form->addElement('radio', 'Weekdays',
array('value' => $d,'checked'=>1),
array('label' => "Day $day", 'content' =>
"content: $d"));
else
$form->addElement('radio', 'Weekdays', array('value'
=> $d),
array('label' => "Day $day", 'content' =>
"content: $d"));
I have found that this does not do what I want:
$tue->setAttribute('checked');
I would like to add them all at once:
$form->addElement('radio', 'Weekdays', array('value' => $d),
array('label' => "Day $day", 'content' =>
"content: $d", 'options' => $Wdays));
.... later on specify default:
$form->addDataSource(new HTML_QuickForm2_DataSource_Array('Weekdays' =>
'Tue'));
Can I already do something like that ?
Regards
--
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Past chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h>