Re: Quickform grouped element question

From: Date: Wed, 23 Apr 2003 09:26:36 +0000
Subject: Re: Quickform grouped element question
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-5011@lists.php.net to get a copy of this message
<hw@xs4all.nl> wrote : > 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 > />'); Try : foreach ($genres as $id => $label) { $checkboxes[] = &HTML_QuickForm::createElement('checkbox', $id, null, $label); } $form->addGroup($checkboxes, 'genres', 'Genres:', '<br />'); Bertrand Mansion Mamasam

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