Re: Creating multiple elements of the same fields into an array with FormBuilder
| From: | Justin Patrin | Date: | Tue, 25 Oct 2005 16:21:56 +0000 |
| Subject: | Re: Creating multiple elements of the same fields into an array with FormBuilder | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21634@lists.php.net to get a copy of this message | ||
On 10/25/05, Dan Rossi <pear@electroteque.org> wrote:
> I dont use formbuilder to post process the data into records , as i
> handle these in a post request method which does other processing.
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.
> But
> ill take a look at those possibilities. As for an array elementname,
> quickform wont let you do it no, it craps out.
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.
>
> On 25/10/2005, at 2:00 AM, Justin Patrin wrote:
>
> > On 10/24/05, Dan Rossi <pear@electroteque.org> wrote:
> >>
> >> On 23/10/2005, at 4:26 AM, Justin Patrin wrote:
> >>
> >>>>>
> >>>>>
> >>>
> >>> My advice is not to use an array and to use SubForm with multiple
> >>> FBs,
> >>> one for each record. Use an elementNamePrefix and/or
> >>> elementNamePostfix to differentiate them. (*not* [] or anything with
> >>> [
> >>> or ], use a normal string like _record_$n). If you need it to display
> >>> in a table you can try to alter the QF renderer to display it
> >>> differently (although I'm not sure how well this will work due to
> >>> SubForm's hacked display methods).
> >>>
> >>> The other option would be to create an FB and form for each song,
> >>> then
> >>> extract the elements and insert them into a table. I would suggest
> >>> trying FB's ElementTable for this.
> >>>
> >>> --
> >>> Justin Patrin
> >>>
> >>
> >>
> >> Umm im a bit vague what you mean, but i can take a look, i seriously
> >> dont think data to extra into the db is easier using
> >> fieldname_record_1
> >> rather than fieldname[] , as it creates an array which u can loop
> >> through and insert/update . Quickform doesnt seem to let you do this,
> >> is this a flaw ?
> >>
> >
> > If you're using FormBuilder it's automatic, you don't have to loop
> > through anything.
> >
> > QF will let you do such a thing, but it may not allow you to do it in
> > groups....I'm really not sure.
> >
> > --
> > Justin Patrin
> >
> > --
> > PEAR General Mailing List (http://pear.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
--
Justin Patrin