Re: DB_DataObject_FormBuilder questions
| From: | Markus Wolff | Date: | Thu, 30 Dec 2004 11:35:45 +0000 |
| Subject: | Re: DB_DataObject_FormBuilder questions | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16515@lists.php.net to get a copy of this message | ||
Peter Bowyer wrote:
Hi, I have a couple of questions about using DB_DataObject_FormBuilder: - How can I freeze one particular field? When editing existing Users (as opposed to adding new ones) the username field of my form needs to be uneditable.Hi Peter, you can define a postGenerateForm() method and freeze individual fields there: function postGenerateForm(&$form) {
$form->freeze(array('field1','field2','field3'));
}
- I have been using $formBuilder->fieldLabels = ... to set friendly labels for my form. That's great, but some fields have to be recreated in the DB_DO class-located function preGenerateForm(), to change the field type. And values in the fieldLabels array for these fields are overridden. Is there any way to prevent this happening, as the DB_DO classes are very much common/core parts of this application, hopefully installed in one central location for a group of clients. Therefore anything needing to be customised should be located outside them - plus this makes multilingual use much easier. (As an aside, I'm guessing to keep this 'pure' I should subclass the DB_DO-generated class and put these FormBuilder methods in there, then modify the class on a per-installation basis. But I'd still like the labels set all from one place :-))I can see only two possibilies here and you already mentioned one of them (subclassing the DO). The other is to have a central configuration file that contains all field labels for all DOs (or one config file per DO, choice is up to you) that will be used from inside the DO class when the fields are generated, and/or also to fill the "normal" fieldLabels property. For FormBuilder itself, I think this is a bit out of scope. CU Markus