Re: FormBuilder DataObject configuration issue
| From: | Justin Patrin | Date: | Thu, 28 Sep 2006 15:05:14 +0000 |
| Subject: | Re: FormBuilder DataObject configuration issue | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25280@lists.php.net to get a copy of this message | ||
On 9/28/06, Alessandro Pasotti <ale.pas@tiscali.it> wrote:
Hello, I have a big problem here: some fields in my DO are FK to thousands of records, I've already setup a convenient filter to enter data, but when I want to display them in a frozen form it obviously takes forever to render. This is useless since I already know which particular value I want to show for the FK field. I thought about setting userEditableFields to array() and then checking if the field is frozen (=userEditable) before calling getSelectOptions() but the funcion _getUserEditableFields() has a check that returns false for an empty $this->userEditableField array It is like this,Hmmm...that might be possible. Of course that won't work if you're just *freezing* the form. The way that I've solved this in my own projects is to use the prepareLinkedDataObject callback to set up the DO to only pull the one record that needs to be shown. http://pear.reversefold.com/dokuwiki/doku.php?id=pear:db_dataobject_formbuilder:callback_methods#preparelinkeddataobject_linkeddataobject_field function prepareLinkedDataObject(&$do, $field) { if ($field == 'fieldName' && $this->freeze) { $do->id = $this->field_id; } } Then set $do->freeze = true on your DO when you want it frozen. -- Justin Patrinfunction _getUserEditableFields() { // if you don't want any of your fields to be editable by the user,set fb_userEditableFields to// "array()" in your DataObject-derived class if ($this->userEditableFields) { return $this->userEditableFields; }would'nt be better to check for array type, like this?function _getUserEditableFields() { // if you don't want any of your fields to be editable by the user,set fb_userEditableFields to// "array()" in your DataObject-derived class if (is_array($this->userEditableFields)) { return $this->userEditableFields; }Additionally, maybe we could also check if the field is editable before calling getSelectOptions() around line 1200 of FormBuilder.php. Any hint, suggestion?