DB_DataObject_FormBuilder - hiding linked values
| From: | Erik Lemcke | Date: | Thu, 21 Jun 2007 15:24:02 +0000 |
| Subject: | DB_DataObject_FormBuilder - hiding linked values | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-27531@lists.php.net to get a copy of this message | ||
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?
This message has been scanned for malware by SurfControl plc. www.surfcontrol.com