Re: HTMLQuickform: Groups, grouping elements graphically, but leaving them ungroup programmatically

From: Date: Sun, 06 Feb 2005 05:44:29 +0000
Subject: Re: HTMLQuickform: Groups, grouping elements graphically, but leaving them ungroup programmatically
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17409@lists.php.net to get a copy of this message
On Sat, 05 Feb 2005 15:39:43 +0000, Aaron <lists.php.net@rare.as> wrote: > Hi there, I have googled for a soloution to this, but there is no solid > source of docmentation that I could find regarding HTML quickform > groups. I have also logged in to irc but had no joy there either. I have > read through most of the documentation for QF but there are missing bits > =/ So this is my current last resort. > > I want to graphically group several checkbox elements together, as they > apply to a common theme. Using css with a group Element, I can have the > checkboxes nicely and graphically layed out in a group like format. > > However I want to be able to access the values of these elements as if > they were not in a group. Which would make it simpler programatically to > set the boolean values in-to mysql as I currently do not know of a way > to do this with grouped elements on just one line. > > e.g. > mysql_field = " . intval($element->getChecked()) ." > > Q2. How about accesing those grouped element values with *one line* of > script then, is this possible? I guess I want to do something like > e.g. > $groupElement->getElement('open_to_females')->getChecked(); > (obviously this doesn't work; can you tell i'm still learning php?) > > I know that one soloution is to bypass the quickform methods and access > the values directly from the post/get variables, but this seems a bit > tardy to me. Well....they way (IMHO) that you're supposed to process QF values is with the process() method. function processForm($values) { echo $values['element']; } $form->process('processForm'); This gives you an assoc array of all of the submitted values and doesn't do any grouping (unless, of course, you told QF to prefix the names with the group name). You can also use: $values = $form->exportValues(); echo $values['element']; if you don't want to use a callback. > > ------ > Next Question > I populate most variables by simply passing the array of mysql values to > the $form->setDefaults method. > > e.g. > $arr_values = mysql_fetch_assoc(mysql_query("SELECT * FROM event WHERE > EventID = $EventID")); > $form->setDefaults($arr_values); > > $arr_Open_to[] =& > > HTML_QuickForm::createElement('checkbox','Open_to_females',null,'Females', > ($arr_values['Open_to_females'] == > 1?"checked=\"checked\"":"") ); > > Q1. Anyone know if there is away to set the default checked value of a > checkbox element to "checked/unchecked" by using $form->setDefaults or > something similar? > Using setDefaults should work fine (I recently had cause to try this with FormBuilder). Did you try? -- Justin Patrin

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