(Solution) Re: [PEAR] quickform checkbox qustion
| From: | Charles Kline | Date: | Mon, 31 Mar 2003 00:28:29 +0000 |
| Subject: | (Solution) Re: [PEAR] quickform checkbox qustion | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4536@lists.php.net to get a copy of this message | ||
B,
Thanks again for the pointer. I have it working now! QuickForm is unreal!
My solution in case others find this helpful:
Part of my QuickForm:
=========================================
foreach ($sth as $k=>$v){
$checkbox[] = &HTML_QuickForm::createElement('checkbox', $k, null, $v);
}
$ib_form->addGroup($checkbox, 'ib_article', 'Choose source articles:', array(' ', '<br />'));
Then on my receiving page:
=========================================
$article_arr = $ib_form->getSubmitValue("ib_article");
$article_keys = array_keys($article_arr);
:
:
foreach($article_keys as $articleid)
{
$insert[] = "('$v_ib_id','$articleid')";
}
$article_sql = "INSERT INTO tbl_ib_articles (issue_brief,article) VALUES " . implode(',',$insert);
Cheers,
Charles
On Sunday, March 30, 2003, at 02:36 PM, Bertrand Mansion wrote:
<ckline@rightcode.net> wrote :hi all, i can't figure out exactly how to get my group of checkboxes to contain the right data. here is what i have: foreach ($sth as $k=>$v){ $checkbox[] = &HTML_QuickForm::createElement('checkbox', $k, null, $v); } $ib_form->addGroup($checkbox, 'ib_article', 'Choose source articles:', array(' ', '<br />')); this gives me this set of checkboxes: <input name="ib_article[30]" type="checkbox" value="1" />Article A <input name="ib_article[20]" type="checkbox" value="1" />Article B<br /><input name="ib_article[31]" type="checkbox" value="1" />Article C this is almost there, but what i want to have is this: <input name="ib_article[]" type="checkbox" value="30" />Article A <input name="ib_article[]" type="checkbox" value="20" />Article B<br /><input name="ib_article[]" type="checkbox" value="31" />Article C where the value="" is the value of $k and the name is just ib_article[] - the $v is showing up just the way i like it right now. how is this achieved? thanks.Hi, That's the way QuickForm handles checkboxes, you can't change it. You can still use array_keys($array) or array_keys($array, 1) to process your checkboxes array. Bertrand Mansion Mamasam