Home » Database » DB_DataObject_FormBuilder » Bug #2978
Allow adding additional attributes to form elements
Details
| Request #2978 | Allow adding additional attributes to form elements |
|---|---|
| Submitted | 2004-12-16 17:37 UTC |
| From | edragon at yahoo dot com |
| Assigned | justinpatrin |
| Status | Closed |
| Package | DB_DataObject_FormBuilder |
| PHP Version | 4.3.8 |
| OS | All |
| Roadmaps | (Not assigned) |
Comments
[2004-12-16 17:37 UTC] edragon at yahoo dot com
Description:
------------
I implemented a site using formbuilder but soon realized that there seemed to be no way to pass a additional attributes to the form elements being created. As they are all being called with the basic '$this->_createTextField($key);' There is no easy way (That I could find) to pass additional options to be generated to my form elements other than predefining basically every one. Standard HTML attributes like 'size', 'maxlength' or 'rows/cols' (For textareas) just to name a few are quite useful to have (And quickform supports doing this). The reasons for this seem obvious to me, database constraints, look/style, usability.
I'd propose having a new array like $fb_fieldLabels called $fb_fieldAttributes that we could define just a string of these is to get used when creating these Elements that support attributes. I hacked and implemented it like this, but it would be nice (and relatively easy) to add this to the official package. Looks like a few other packages have implemented this too, as other results came up when I tried to submit.
Thanks!
[2004-12-16 19:35 UTC] edragon at yahoo dot com
I suppose doing to like that would work, but its not much different or much less code than just doing it for all fields in preGenerateForm too, basically eliminating the need really to use FormBuilder for anything in the first place. (If I make a preGenerated element for every element, I can just go directly through Quickform)
The way I had it written in the constructor, it was just in with the fieldlabels as:
$this->fb_fieldAttributes=array('name'=>'maxlength=50 size=50','bio'=>'rows=4','research'=>'rows=4','currentresearch'=>'rows=4','currentclasses'=>'rows=4');
Which seemed better and easier to change than 10-20 lines of extra code somewhere else in the class. I personally think that since Quickform has this as one of the optional parameters, and everything ends up going through quickform anyway, and attributes are as important as name and label that FB should have some easy, defined way to override sizes, as without it you can get a neary unusable form (Default of 2 rows for a text area, no way to apply styles, etc.) , but I guess I can just rewrite everything to do it the long way if this is your preference. I have to rewrite the classes to all work in the newer versions anyway.