Re: Betr.: Re: [PEAR] DB_DataObject_FormBuilder - hiding linked values
| From: | Justin Patrin | Date: | Fri, 22 Jun 2007 16:54:29 +0000 |
| Subject: | Re: Betr.: Re: [PEAR] DB_DataObject_FormBuilder - hiding linked values | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-27539@lists.php.net to get a copy of this message | ||
On 6/22/07, Erik Lemcke <ELemcke@wwf.nl> wrote:
Hi justin, Thanks for your answer. The best solution I think would be to not have the fields in the form at all, since they aren't of any use for the user. Updating them after the insert would be my choise too, but how do I get the id of the inserted record? (I would need that to update the record) Is there a way to get that id after $form->process(array(&$fg, 'processForm'), false); is executed? or should it be done with some callback function?Please respond to the list. The DO is updated when process happens so you can just do it with the same DO you pass to FB.
Regards, Erik-- Justin Patrin<432beae0706210837g50cf0d43i25576705c4351dee@mail.gmail.com> door "Justin Patrin" <papercrane@gmail.com> geschreven: On 6/21/07, Erik Lemcke <ELemcke@wwf.nl> wrote: I have a little problem with a form I'm building with formbuilder. Besides the data entered in the form, I want to store which user filled the form. For that I have a table users, linked to the table that the form is generated (called dc_document) for (so in that table, there is a field creat_user_id) Formbuilder makes a nice select box, so you can select the username (from the linked users table) Since I use auth to authenticate, I already know the userid of the user that is filling the form, so I can set the value when I create the form like in this small example: //create the dataobject $document = DB_DataObject::factory('Dc_document'); //set the user id $document->user_id = $user_id; //create the form $fg = DB_DataObject_FormBuilder::create($document); $form = $fg->getForm('index.php'); if ($form->validate()) { $form->process(array(&$fg, 'processForm'), false); } else { echo $form->toHtml()); } So the user select box is now set to the currently logged in user. That's great, but I don't want the user to be able to alter that value. I've tried doing that by making the select box hidden, like I would do with a input box, but that didn't work (since usually there's no point in making a html select box when it's hidden) So there's possible a better way to store the user id in the database while not showing it in the form, I just can't find out how to do it. Any ideas? A few thoughts. You could always just freeze the user select field when the user is logged in so that they can see it but not edit it. Couple this with prepareLinkedDataObject to make the field only show the logged in user (to stop pointless record fetching) and you have a decent solution. You could also just not put the user field in the userEditableFields / fieldsToRender and set it and update() yourself after the form has been processed. -- Justin Patrin -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Click on the following link to report this email as spam. https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg==>Op Do, jun 21, 2007 om 5:37 is in bericht