FormBuilder -- generating one form from multiple forms

From: Date: Sun, 18 Sep 2005 15:56:11 +0000
Subject: FormBuilder -- generating one form from multiple forms
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21023@lists.php.net to get a copy of this message
I am trying to set up FormBuilder to generate one form from multiple forms -- so each row in my database table appears as a row in the form, allowing for a quick review/edit of the whole table. Here's what I have: // Get all primary keys for the table. $primary_keys = $db->getCol( "SELECT Record_ID FROM $db_table ORDER BY Record_ID ASC" ); // Get all the DataObjects and FormBuilder objects first. foreach( $primary_keys AS $key ) { $dataobject[ $key ] =& DB_DataObject::factory( $db_table ); $dataobject[ $key ]->get( $key ); $formbuilder[ $key ] =& DB_DataObject_FormBuilder::create( $dataobject[ $key ] ); $formbuilder[ $key ]->elementNamePrefix = $key."__"; } // Create the form $form = $formbuilder[ 0 ]->getForm(); // Everything fine so far. I can test it here and it displays form for // the first row in the database table. // Add all the other rows to this form. for( $i = 1; $i < count( formbuilder ); $i++ ) { $formbuilder[ $i ]->useForm( $form ); $formbuilder[ $i ]->getForm(); } $form->display(); This, unfortunately, causes a form to be generated for each row. I see, in this case, 150 forms on the page, each with their own submit button, rather than one form with 150 groups of elements, all having only one submit button. All the elements are, however, correctly names with the prefix. [form header] [field1 label]: [001__text_field_1] [field2 label]: [001__text_field_2] [submit button] [form header] [field1 label]: [002__text_field_1] [field2 label]: [002__text_field_2] [submit button] and so on, for 150 "rows". At this point, I'm not setting any other options or trying anything with any formatting. -- I'm just trying to keep it simple. So what am I missing? Thanks for any help. Wes

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