Re: Creating multiple elements of the same fields into an array with FormBuilder

From: Date: Sun, 30 Oct 2005 16:49:46 +0000
Subject: Re: Creating multiple elements of the same fields into an array with FormBuilder
References: 1 2 3 4 5 6 7 8  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21706@lists.php.net to get a copy of this message
On 10/27/05, Dan Rossi <pear@electroteque.org> wrote: > > On 26/10/2005, at 2:21 AM, Justin Patrin wrote: > > >> > > > > I suggest if you're using FormBuilder to create the form you also do > > processing with it. You can always do other things with the data as > > well. Take a look at pre and postProcessFormCallback. > > > >> > > > > Actually, yes it will. > > require_once('HTML/QuickForm.php'); > > $form = new HTML_QuickForm(); > > $form->addElement('text', 'arr[]', 'Element 0'); > > $form->addElement('text', 'arr[]', 'Element 1'); > > $form->addElement('text', 'arr[]', 'Element 2'); > > $form->display(); > > > > "It craps out" isn't a very good explanation. What *exactly* happens. > > QF won't let you, for example, use the same element name for different > > element *types*. But it's fine in the above example. > > > > Ok yes that works i meant in formbuilder. Sorry, I don't know what you mean. How are you trying to do this? > Anyway is there a subForm > example i can work off ? Yes, the comments in the SubForm file have an example in them. There's also my test script: http://pear.reversefold.com/SubFormTest.php > In particular im not displaying a list of > current records, but for the insertion page a changable list of > elements to insert records into the track titles table. Same thing as updating multiple records. Go through a loop and add a unique elementNamePrefix to each one. FormBuilder *can handle this*, as I've been saying for a while now. > That is you > can update how many rows/elements to display and insert hence the > elementnames with [] appended to them is the best solution i think > unless FB can handle it ? [] is for when *you* are going to manually process something. You don't need it if you let FormBuilder handle it. It deals with elementNamePrefix automatically. > I may aswell just use standard html form > elements inside the template ? > -- Justin Patrin

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