Quickform grouped element question
| From: | Hans Westerbeek | Date: | Wed, 23 Apr 2003 09:09:17 +0000 |
| Subject: | Quickform grouped element question | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-5010@lists.php.net to get a copy of this message | ||
Hi all,
With the latest beta of Quickform I am trying to get a bunch of checkboxes in the form, each with the same name, and in a group.
So I looked at the examples and ended up with this piece of code:
--------
$genres = $this->_getGenres();// fetch genres in an array as id => genrename
// Creates a checkboxes group using an array of separators
$checkboxes = array();
foreach ($genres as $id => $label)
{
$box = &HTML_QuickForm::createElement('checkbox', null, null, $label);
$box->setValue($id);
$checkboxes[] = $box;
}
$form->addGroup($checkboxes, 'genres[]', 'Genres:', '<br />');
-----
But that yields this error, which I am really in the dark about:
[error_message_prefix] => QuickForm Error:
[mode] => 4
[level] => 1024
[code] => -5
[message] => unregistered element
[userinfo] => Element 'genres[]' does not exist in HTML_QuickForm::_loadElement()
-----
Now what I think is part of the problem is that I am confused by Quickform's API.
Can one of you help me out?
Regards,
Hans