FormBuilder help

From: Date: Thu, 25 May 2006 05:20:36 +0000
Subject: FormBuilder help
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-24146@lists.php.net to get a copy of this message
Hi, Here is what I am attempting to do using FormBuilder. I have two tables, cities (cities_id INT auto_increment) and cities_description (cities_id, languages_id, cities_name). I want FormBuilder to make a form that will add a new entry to cities and cities_description. The trick I'm trying to use is to have two forms in one, as in the rapidprototyping-kr-1.pdf. What I would like it to do is create a new entry in cities first, and use the resulting cities_id to create the new entry in cities_description. Here is my code : <?php $description = DB_DataObject::factory('cities_description'); /// this is because (cities_id,languages_id) is the primary key/ $description->keys('id'); $city = DB_DataObject::factory('cities'); $city->createSubmit=*false*; $descriptionBuilder =& DB_DataObject_FormBuilder::create($description); $cityBuilder =& DB_DataObject_FormBuilder::create($city); $cityBuilder->elementNamePrefix = 'city'; $cityForm =& $cityBuilder->getForm(); $descriptionBuilder->elementNamePrefix = 'description'; $descriptionBuilder->useForm($cityForm); $combinedForm =& $descriptionBuilder->getForm(); /// Create a FormBuilder for the post/ $formBuilder = &DB_DataObject_FormBuilder::create( $description ); /// Actually fetch the Form/ $form = &$formBuilder->getForm( ); /// If we validate, then we process it here/ if( $form->validate( ) ) { $form->process( array( &$formBuilder, 'processForm' ), *false* ); /// Redirect/ header( "Location: http://" . $_SERVER[ 'HTTP_HOST' ] . dirname( $_SERVER[ 'PHP_SELF' ] ) . "/test4.php" ); } $form->display( ); *?>* Any help would be welcome. Thank you, Patrick

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