Re: QuickForm issue

From: Date: Mon, 17 Jun 2002 14:36:34 +0000
Subject: Re: QuickForm issue
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1690@lists.php.net to get a copy of this message
<bmansion@mamasam.com> wrote : > <david@ddahl.com> wrote : > >> Well, i looked at both of the setConstants and setDefaults methods... so >> I put this in my code: >> >> $userFormEdit->addElement('text', 'namel', 'Last Name'); >> $userFormEdit->setConstants(array ('namel' => $row['namel'])); >> >> >> and i tried it like this: >> >> $formConstantsEdit = array('namel' => $row['namel']); >> $userFormEdit->addElement('text', 'namel', 'Last Name'); >> $userFormEdit->setConstants($formConstantsEdit); >> >> both output the form like this: >> >> <tr> >> <td align="right" valign="top"><b>Last >> Name</b></td> >> <td nowrap="nowrap" valign="top" align="left"><input >> name="namel" >> type="text" /></td> >> </tr> >> >> Can you spell it out for me? > > Just set the values before adding the elements. Prepare an array with all > the values you need for all the elements you need, then setDefaults or > setConstants with this array, then addElement. It is just an habit to have > to handle the raw data first. I forgot to say, for the ones who forgot that quickform is object-oriented like ooh_form, that you can also set a value for an element this way if you prefer: $name = &HTML_QuickForm::createElement('text', 'namel', 'Last Name'); $name->setValue('hello world'); $userForm->addElement($name); Bertrand Mansion Mamasam

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