Home » Database » DB_DataObject_FormBuilder » Bug #5682
required custom fields on subform
Details
| Submitted | 2005-10-13 09:05 UTC |
|---|---|
| From | sdc at spiretech dot com |
| Assigned | justinpatrin |
| Status | Bogus |
| Package | DB_DataObject_FormBuilder |
| PHP Version | 4.3.4 |
| OS | RH Linux |
| Roadmaps | (Not assigned) |
Comments
[2005-10-13 09:05 UTC] sdc at spiretech dot com
Description:
------------
I have a problem with the "required" asterisk not appearing on subforms that contain a custom input of file type. It might happen with other custom field modifications too, but I haven't checked anything except file.
Again not sure if this is a problem with FB or HTML_quickform.
I think everything is OK with my code because the asterisk shows up on the form when the table is viewed by itself, but not on a subform. I've tried setting the $fb_fieldsRequired array to the altered fieldname (and the base fieldname) to no avail.
It's sort of a minor annoyance, but it does cause the form to choke on submit if someone omits the file.
Test script:
---------------
// ovverridden preGenerateForm Prepare the form so it contains a file upload field
function preGenerateForm(&$fb) {
$this->subfieldname=$fb->getFieldName('icon');
$el = & HTML_QuickForm::createElement('file', $this->subfieldname, 'Icon');
$this->fb_preDefElements['icon'] = $el;}
}
Expected result:
----------------
a * (asterisk character) next to the required custom field on a subform. field validation for NOT NULL on submit.
Actual result:
--------------
Asterisk only appears on custom field when form is used by itself. Subform version of form shows no asterisk and does not check for required.
[2005-10-13 21:41 UTC] sdc at spiretech dot com
I over-simplified the example code I posted and got carried away. I'm already calling populateOptions.
// ovverridden preGenerateForm Prepare the form so it contains a file
upload field
function preGenerateForm(&$fb) {
$fb->populateOptions(); //load the variables we need from formbuilder
$this->subfieldname=$fb->getFieldName('icon');
$el = & HTML_QuickForm::createElement('file',
$this->subfieldname, 'Icon');
$this->fb_preDefElements['icon'] = $el;}
}
[2005-10-13 22:29 UTC] sdc at spiretech dot com
yes, it's not null.
remember the required * shows up on the form when viewed by itself, but not when viewed on a subform. that leads me to believe that something is going wrong down in the guts somewhere.
I've experiemented around with different variations of forcing the required thing to happen without any success:
//$fb_fieldsRequired=array("$this->subfieldname", 'icon');
I have it commented out right now cause it doesn't seem to make any difference.
[2005-10-13 22:48 UTC] sdc at spiretech dot com
@version $Id: FormBuilder.php,v 1.208 2005/10/07 23:56:24 justinpatrin Exp $
[2005-10-13 23:42 UTC] sdc at spiretech dot com
ok, looking at the form object clued me into what was going on.
The field was inside a group.
taking it out of the group caused it to work properly.
I have a need to create a small group (on update, not insert) that shows an image of the current file. they are just little icon bitmaps.
So how, in preGenerateForm do you tell if you are doing a form for an insert or an update?
and what would be the recommended procedure for replacing a single field element with a group, and retain the proper behavior of the group's elements?
Thanks for all your help. I'm also using your FB FrontEnd with good results.
[2005-10-14 07:07 UTC] sdc at spiretech dot com
I removed the group to get it working. the asterisk showed up now.. but it doesn't seem to enforce the file field being empty - insert gets called regardless and no field required message is shown when the form is validated.
but I'm about ready to give up fighting with it.
[2005-10-16 07:23 UTC] sdc at spiretech dot com
I was getting ready to try your patch and give the QF guys feedback, but it looks like they aren't going to change the way they are doing things for us, so I'm going to live with it the way it is. If I get ambitious, I'll see what I can do to make my stuff work their way.