Re: fb nested forms problem
| From: | Leo Márquez | Date: | Fri, 01 Jun 2007 09:23:38 +0000 |
| Subject: | Re: fb nested forms problem | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-27381@lists.php.net to get a copy of this message | ||
Hi again and thanks for your answer.
We have reviwed documentation and have did some changes in database. Now we have this scenario:
CENTRALETA
---------------
ID_CENTRALETA (PK autoincr)
REF_CENTRALETA MODEL
NOM
FOTO
CENTRALETA_IDIOMA
-----------------
ID_CENTRALETA_IDIOMA (PK autoincr)
REF_CENTRALETA (FK)
CODI_IDIOMA
DESCRIPCIO
links.ini
[CENTRALETA_IDIOMA]
REF_CENTRALETA=CENTRALETA:REF_CENTRALETA
And now all works fine.
Thanks.
En/na Justin Patrin ha escrit:
On 5/30/07, Leo Márquez <leo@calidae.net> wrote:-- Leo Márquez [ Calidae - www.calidae.com ]Hi, I'm playing with formbuilder. I need a nested form between this two tables CENTRALETA --------------- ID_CENTRALETA (PK) REF_CENTRALETA (FK) MODEL NOM FOTO CENTRALETA_IDIOMA ----------------- REF_CENTRALETA (PK) CODI_IDIOMA DESCRIPCIO links.ini [CENTRALETA] REF_CENTRALETA=CENTRALETA_IDIOMA:REF_CENTRALETA The problem I have is that the REF_CENTRALETA field of the CENTRALETA_IDIOMA table is not filled when I do insert. The source th generate the form is here: $do = DB_DataObject::factory('CENTRALETA'); $do->get($_REQUEST['idget']); $fb = DB_DataObject_FormBuilder::create($do); $fb->addFormHeader=false; $fb->createSubmit = false; $fb->elementNamePrefix = 'frmCentraleta'; $form = $fb->getForm(); $do2 = DB_DataObject::factory('CENTRALETA_IDIOMA'); $do2->get($do->REF_CENTRALETA); $fb2 = DB_DataObject_FormBuilder::create($do2); $fb2->addFormHeader=false; $fb2->elementNamePrefix = 'frmCentraletaIdioma'; $fb2->useForm($form); $form = $fb2->getForm(); if ($form->validate()) { $form->process(array(&$fb, 'processForm'), false); $form->process(array(&$fb2, 'processForm'), false); } echo $form->toHtml();Well, of course that field is not going to be filled out, FormBuilder is doing exactly what you asked it to. You're creating 2 different forms for 2 different tables and then processing them seperately. What you need to do it process the sub-record first, then set that field in the other record's DO before processing it. Something like: if ($form->validate()) { $form->process(array(&$fb2, 'processForm'), false); $do->REF_CENTRALETA = $do2->REF_CENTRALETA; $form->process(array(&$fb, 'processForm'), false); }