Re: DB_DataObject_FormBuilder: Group Handling
| From: | Justin Patrin | Date: | Tue, 07 Dec 2004 22:18:27 +0000 |
| Subject: | Re: DB_DataObject_FormBuilder: Group Handling | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-16094@lists.php.net to get a copy of this message | ||
On Mon, 6 Dec 2004 11:50:13 +0100, Sönke Ruempler
<ruempler@topconcepts.com> wrote:
> Hi,
>
> I'm trying to add a QuickForm Group for a File Upload Field in Formbuilder.
> The Field is represented as varchar field in the table and should save the
> file extension.
>
> I have an own DataObject Class where I want to put standard methods for
> forms, and also for file upload fields. For each file upload field I want to
> generate a group of elements with the field on it's own, a link to show the
> uploaded file (if something is uploaded) and a checkbox to delete a existing
> upload file.
>
> While experimenting with FormBuilder I noticed that I can
>
> 1) Use preDefElements with arrays to create the group like
>
> public function preGenerateForm($fb) {
> if (isset($fb->_do->fb_fileUploadFields)) {
> foreach ($fb->_do->fb_fileUploadFields as
> $uploadFieldName => $uploadField) {
>
> $fb->_do->fb_preDefElements[$uploadFieldName] = array(
>
> HTML_QuickForm::createElement('file', $uploadFieldName),
>
> HTML_QuickForm::createElement('text', 'blah')
> );
>
> Now a Group is created, but I can't edit the group seperator, and the field
> names in the form are not like group[element_name]. fb_fileUploadFields is
> my own variable that indicates which fields are upload fields.
>
Well, groups are added that way by design to not screw with the
element names. Changing the element names like that is very
problematic. You can always add the group manually to your form in
postGenerateForm() or put them in a form and use useForm() on thr FB
object.
> 2. Use preDefGroups
>
> I do not understand, why the array is name => group and not, group_name =>
> array of elements. This would imho make more sence.
You're right, it doesn't seem to make much sense. I think it was done
this way to ease lookups (group lookups are done per-element). This
also restricts the group-per-element to one. (i.e. with the way you
proposed it would be possible to have one element in multiple group
arrays). We *could* add an option to alter the separators...how
important is this?
>
> Thx for your help!
>
--
Justin Patrin