I was testing out the new version and saw that a FIle Upload question that is Mandatory doesnt have astericks * like other fields (although validation is fine, it does make sure you are trying to upload something there). Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | webform-file-required_mark_theme.patch | 1.33 KB | arithmetric |
| #10 | webform-file-required_mark.patch | 1.34 KB | arithmetric |
Comments
Comment #1
armyofda12mnkeys commentedI saw in the file.inc code that it says...
' //'#required' => $component['mandatory'], // Drupal core bug with required file uploads' so maybe you guys know about it, uncommenting this line makes the page display the *, but not sure if its safe to uncomment this line as some bug you say occurs?
Comment #2
quicksketchThanks, I think the core bug is simply that it doesn't do anything. Webform has to do the validation manually. However, I didn't think about the asterisk not showing up. I don't think there's any harm in making it required. I'll test if it gives us any trouble, but if you can try it out and post how it goes, that'd be great.
Comment #3
sethcohn commentedSelects (checkboxes and radios) are missing the asterisks as well, and also missing Description fields.
Comment #4
quicksketchsethcohn, I opened a new issue for your request #277270: Select doesn't have description or required. Please continue there.
Comment #5
armyofda12mnkeys commentedwell tested: side effect of this is it validates twice once from Drupal and once from that custom validation maybe?
# Upload your orgs info field is required.
# Upload your orgs info field is required. (italics)
Comment #6
quicksketchCool, yep it looks like this problem has been solved in core. Webform likely included that fix for Drupal 4.7. I've removed the custom validation functions and we can use the ones now provided by core. And, as a bonus the asterisk now shows up. :)
Thanks for your report!
Comment #7
quicksketchDoh! I rolled back my changes because the #required property on file uploads prevents *any* submissions from happening. Even if you do select a file, Drupal thinks there isn't a value and won't allow the submission of the form. Looks like this problem definitely does still exist, even in Drupal 6.
Comment #8
advseb commentedsubscribe
Comment #9
gdkt11 commentedsubscribe
Comment #10
arithmetric commentedOne potential solution is to add the formatted asterisk to the title property of the form element when it's generated.
I'm attaching a patch (against the CVS tag DRUPAL-5--2) that does this.
It doesn't come out quite the same as fields that use the #required property, because theme_form_element puts a colon (:) after the title, so it looks like:
Attach your file here *:
Instead of like:
Attach your file here: *
I wish it could be consistent, but I do think it's important to show that the field is required.
Comment #11
quicksketchThe appropriate way to fix this would be to put a custom #theme property on the form element, then in the theme function add the #required = TRUE property. This way it would have the appearance of being required, but not be mishandled by FAPI.
Comment #12
arithmetric commentedHere's a patch that takes this approach. If the webform file upload field is set to mandatory, then I use a custom theme function to add #required before handing off to theme_file.
Comment #13
eatrains commentedI'm having this same problem.
Comment #14
tawebworks commentedI attempted to run the patch and got this message:
[Tami-Whitesides-Computer-10:~] tamiwhit% patch < /Users/tamiwhit/Desktop/websites/Meck\ Promise/sites/all/modules/webform/components/webform-file-required_mark_theme.patch
can't find file to patch at input line 8
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|Index: file.inc
|===================================================================
|RCS file: /cvs/drupal-contrib/contributions/modules/webform/components/file.inc,v
|retrieving revision 1.2.2.19.2.32
|diff -u -r1.2.2.19.2.32 file.inc
|--- file.inc 4 Mar 2009 05:05:18 -0000 1.2.2.19.2.32
|+++ file.inc 11 Apr 2009 21:38:55 -0000
--------------------------
Can anyone help me with this issue?
Comment #15
quicksketchYou need to be in the directory that contains webform.module. Looks like you ran the patch from your home directory. Please do not ask general patching questions as it can derail the conversation thread.
Comment #16
tawebworks commentedThank you for your assistance, quicksketch. I was able to get the patch applied. Now, where do I ask about a problem caused by that patch? (Just so I know.)
Comment #17
tawebworks commentedDetour, I applied your patch and now my file upload field components disappear completely. Have you had any more chance to work on this patch?
Comment #18
quicksketchI've fixed this in 3.x as part of #216529: File Upload Doesn't Work With Page Break -- Upgrade File Component to use FID values instead of file arrays. Unfortunately this won't make it back to the 2.x version or Drupal 5.
Comment #20
edhel commentedI fix this issue on Drupal 5.6 by such code in template.php: