Re: formBuilder : how to override fb_linkDisplayFields

From: Date: Tue, 18 Oct 2005 16:31:54 +0000
Subject: Re: formBuilder : how to override fb_linkDisplayFields
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21528@lists.php.net to get a copy of this message
On 10/18/05, arnaud sellenet bodin <demental@free.fr> wrote: > Hello > > I have an article table linked to a categories table. This categories > table has two name fields (one for french, one for english). Depending > on the current language used (constant LANG) I would like to display > the right options in the generated SELECT element. > > So I tried this (in Categories.php) : > > function preGenerateForm (&$fb){ > $this->fb_linkDisplayFields=array("name".LANG); > } > > But this has no effect the options are only populated with the PKs of > categories This is because preGenerateForm is called on the DO for which you're generating the form, not for linked DOs. > while doing this : > var $fb_linkDisplayFields=array("name".LANG); > makes a parse error. You can't do processing in a member initialization like this. You have a few possibilities here. You can use the constructor, like you showed in your second e-mail. This should work just fine since DB_DataObject doesn't have a constructor of its own. You could also do something like add a prepareLinkedDataObject function to the DO you're creating the form for and call preGenerateForm on the linked DOs, but I think the constructor is a better solution. -- Justin Patrin

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