QuickForm: setting defaults on dynamic checkbox group

From: Date: Mon, 31 Mar 2003 16:07:44 +0000
Subject: QuickForm: setting defaults on dynamic checkbox group
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4555@lists.php.net to get a copy of this message
hi all, i have a quickform which uses a query to build a list of checkboxes like so: foreach ($sth as $k=>$v){ $checkbox[] = &HTML_QuickForm::createElement('checkbox', $k, null, $v); } $ib_form->addGroup($checkbox, 'ib_article', 'Choose source articles:', array('&nbsp;', '<br />')); For this form, I am trying to create an edit version, and am having trouble getting the previously selected checkboxes to be selected by default when the form builds. I have tried this: $str = ""; foreach ($sth_opt as $key=>$val){ $str .= "array('$val'=>true)"; } echo $str; $defaultValues['ib_article'] = $str; which seems to build the properly formated default string. for example if quickform creates a checkbox like: <input name="ib_article[30]" type="checkbox" value="1" />Test A when I echo $str above I have: array('30'=>true) - so my defaultValues setting should work? It isn't so... what is the way to go about doing this? Thanks, Charles

« previous php.pear.general (#4555) next »