Re: DataObject_FormBuilder conditions

From: Date: Fri, 04 Feb 2005 18:20:33 +0000
Subject: Re: DataObject_FormBuilder conditions
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17390@lists.php.net to get a copy of this message
On Fri, 4 Feb 2005 11:21:40 -0500, James Stewart <lists@jystewart.net> wrote: > I've just started using FormBuilder and am using it for a file upload > system. I want to allow a user to upload files for any of their > clients. What I'd like to produce is a select box with a list of just > this user's clients. > > Using this code and the relevant changes in the DO class, I have a > select box with all the users appearing, but I had hoped the whereAdd > would limit it? > > $users = DB_DataObject::factory('users'); > $file = DB_DataObject::factory('files'); > $file->joinAdd($users); > $file->whereAdd("users.user_parent = $parent_value"); > $build =& DB_DataObject_FormBuilder::create($file); > $this->form = $build->getForm(); > > I can't seem to find anything in the docs about this. Is there a > straightforward way to do what I want? > FormBuilder doesn't use joins for any of this (that just wouldn't work) and a whereAdd like that is never going to work for this. Good try, though. :-) The way to limit values in a select box is to use the prepareLinkedDataObject callback in your DataObject. See the docs: http://opensource.21st.de/tiki-index.php?page=Callback+methods#id427020 -- Justin Patrin

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