Re: FormBuilder nested forms trouble

From: Date: Thu, 22 Nov 2007 03:59:36 +0000
Subject: Re: FormBuilder nested forms trouble
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-28200@lists.php.net to get a copy of this message
On Nov 21, 2007 6:03 PM, Mike <cs169-an@imail.eecs.berkeley.edu> wrote: > Instead of calling process() once for each form, it's once per > FormBuilder. > > The following code seems to be working for me: > > if ($form->validate()) { > foreach ($formBuilders as $formBuilder) { > $form->process(array(&$formBuilder, 'processForm'), false); > } > } > > only one validate() call necessary. > Yes, one validate on the form you display and one process per formbuilder. > still wondering if there is a way to extract the javascript validation > stuff from the last FormBuilder though, or if I should be doing this > another way (with a QuickForm Controller or something?) > > -Mike > > > > On Wed, 21 Nov 2007, Mike wrote: > > > Thanks, I traced into the processForm function, and found that instead of > > calling _getMyValues for each form used in making the nested form, it just > > calls it once. On the nested form, $this->_do->elementNamePrefix is the > > prefix from the last DataObject used, so only the last form's data is > > discovered by _getMyValues, and is the only data that is processed. > > > > I guess $form->validate() and $form->process() have to be called on each form > > used to make the nested form when the nested form is submitted? > > > > Also, I need to display the fields out of the order in which they were added > > to the nested form - I'm currently doing this by picking out the elements > > from _elements array in the nested form and displaying those. I miss out on > > the Javascript validation code this way and possibly other validation related > > stuff that really would like to use... is there a way to get at that info? Am > > I going about it all wrong? ;) > > > > > > Thanks again! > > -Mike > > > > > > On Tue, 20 Nov 2007, Justin Patrin wrote: > > > >> On Nov 20, 2007 4:02 PM, Mike <cs169-an@imail.eecs.berkeley.edu> wrote: > >>> Hi, I've created a nested form that has multiple rows from one table in > >>> it. For some reason, only the last form generated in the sequence of > >>> nested forms actually persists its data to the database. The fields post > >>> the data, but the update statement (from the generated SQL) only takes > >>> care of the last form. > >>> > >>> I've set the field prefixes so each field is unique in the form, and > >>> inspecting the final nested form shows the $_elements array with the > >>> appropriate prepended prefix. HTML looks right too. > >>> > >>> I followed the "nested forms" slide in this slide presentation: > >>> > >>> http://opensource.21st.de/static/formbuilder/rapidprototyping-kr.pdf > >>> > >>> Also, I'm using a WHERE clause on the DataObject before I iterate over it > >>> with fetch() to progressively nest the rows; maybe that's complicating > >>> things? > >>> > >> > >> Make sure the prefixes are set right for each record when you process it. > >> > >> -- > >> Justin Patrin > >> > > > > > -- > > PEAR General Mailing List (http://pear.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Justin Patrin

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