Closed (won't fix)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
18 Dec 2015 at 15:36 UTC
Updated:
20 Dec 2019 at 21:15 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
djschoone commentedComment #3
cstpraveen commentedI can work with this. But I am a beginner. I need some time to do.
Comment #4
anthonyf commentedI've started working on a patch to add an option under webform advanced settings to disable automatic form validation by the browser. The aim is to add the 'novalidate' attribute to the form element if the user selects this option.
Comment #5
anthonyf commentedComment #6
anthonyf commentedI created a patch on 7.x-4.x-dev to add the "novalidate" option to webform configuration.
Run database updates after applying this patch as it adds a new column to the webform schema.
Find the new option in Form Settings, under Advanced Settings, "Disable browser validation".
Comment #7
anthonyf commentedComment #8
hamrant commentedLooks great, checked, everything works, move to rtbc
Comment #9
drclaw commentedAgreed! Patch applies and works as described. Thanks @ajfwebdev!
Comment #10
ivangelo commentedThanks @ajfwebdev! The patch works.
Comment #11
frontmobePatch works perfectly, let's move this to rtbc. Nice functionality, thanks Anthony!
Comment #12
GrantI commentedPatch #6 works perfectly. However...
Remember to run the update.php script. For Drupal newbies if your domain is localhost/drupal then you need the URL localhost/drupal/update.php Very good idea to backup your database before you do so, just incase the worst happens.
Comment #13
danchadwick commentedWhat is the use case for not wanting browser validation? Why do you want to let the user submit the form and then report the error? We strive to add only the most essential features to webform to prevent feature bloat.
You can add no-validate by modifying the form in a custom module, for example.
If you feel you have a compelling argument for this feature that would apply to a fair number of webform users, please reopen this issue.
Comment #14
finex commentedHere is one usecase: if you're using jQuery plugins like Chosen or Selectric on required select field, the HTML5 validation system doesn't work.
Comment #15
anthonyf commentedHi @DanChadwick,
The use case that prompted Patch #6 was that browser validation was not working correctly in some browsers. An alternative validation method was needed in those cases, but first there had to be a way to disable the default browser validation.
Comment #16
liam morlandIs this still a problem? In what ways was the browser validation not working correctly?
As it says in #13, a custom module could be used to adjust the form if desired.
Comment #17
john_b commentedThis is absolutely needed. Errors in markup my be found in Webform sub-modules which have an official release, which trigger unwanted browser form validation, and which can be difficult to trace. I have encoutered this with select lists of prodcuts generated by Commerce Webform, a module whose maintainer is usually too busy to fix. Of the course the draconian approach is to say, 'just sort it, it is not a Webform issue'. Seems a bit harsh?
Comment #18
liam morlandMarkup errors need to be fixed in the module that is creating the error. Remember you can always run a modded version of a module if you need to run a patch before it is accepted on d.o.
Comment #19
chris burge commentedIt doesn't sound like this patch is getting in. Here's how I disabled HTML5 validation on all webforms:
If you only want this for certain forms, you can change the IF logic. Bottom line - you'll be controlling the 'novalidate' attribute in code, not in DB. That's why I disabled it on all webforms. My users creating webforms can't push code, so I disabled HTML5 validation for everyone.
Note: Modified per #21 below.
Comment #20
john_b commentedThanks.
I probably will fix the module which is giving me a problem, unless someone esle does. Of course that is the right way to do it. A patch to disable browser validation would give users without those skills a helping hand: we do not want them to feel that the Drupal culture says, 'if you are not a coder, hire a coder or go away'.
Comment #21
liam morlandWe also need a culture where problems are fixed at their source.
I am not completely opposed to this request. The patch needs a re-roll and needs to include tests for the attribute and the control for it.
The attribute should be set as the empty string; that is a valid way to display Boolean attributes:
$form['#attributes']['novalidate'] = '';This can be improved once #2847484: Support boolean attributes in drupal_attributes() is committed.
Comment #22
blacklabel_tom commented+1 this for D8 :)
Comment #23
liam morlandPlease open a child ticket for D8.
Comment #24
blacklabel_tom commentedD8 ticket here: https://www.drupal.org/project/webform/issues/2987499
Comment #25
brtamas commentedComment #26
liam morlandComment #28
brtamas commentedComment #29
jenlamptonThe last patch was submitted with no explanation, but I'm guessing we need to run the tests on it again? Changing status.
Comment #30
liam morlandThis patch needs re-roll so that it applies to the current tip of branch 7.x-4.x.
Comment #31
jenlamptonThe difference between the two provided patches was the update number.
webform_update_7431()vswebform_update_7432().The patch in #28 applies (with fuzz) to 7.x-4.20 as well as 7.x-4.x.
Resubmitting here in the hopes of getting this in soon. All webforms with conditional requirements are currently broken in Chrome (or any browser that uses HTML5 validation). Hm, after stating that - bumping up priority to Major.
Comment #32
danchadwick commented@jenlampton - Uh, wut? Is there a related issues for validation + conditionals being broken in Chrome? If not, please create one and reference it here.
I just created a webfom with a required field that is conditionally shown. It seems to work fine in Chrome (Windows, 76.0.3809.100) -- i.e. the required field is not required while it is hidden. Certainly we would want to fix the root issue (unless its impossible), rather than provide the work-around of novalidate.
Comment #33
liam morlandI think the best solution to this is to provide documentation for how to add the attribute using hook_form_alter(). This sound like something few people would want and it clutters the interface to have it. Someone could also write a module which implements this.
Comment #34
rudi teschner commentedI have similar problems with required hidden fields though my result from a combination of required hidden fields with chosen library.
I havent been able to find a solution directly within the library or the drupal module, but disabling browser validation seems to be a proper workaround - especially considering the required effort to find a solution.
At least it prevents the faulty browser validation in my case.
Since actual browser validation differs depending on the actual browser and thereby is a "risk factor" anyway ... it might not be a bad idea for complex webforms to add this option to the webform module.
I've also found some detailed evaluation of relying on browser validation to add some additional information to this issue: https://intopia.digital/articles/default-browser-error-messages/
Comment #35
jenlamptonAh, thanks @Rudi Teschner, I have confirmed that my site with the broken required hidden fields also has Chosen, so it's likely that library is affecting the webform's hidden required fields. I was not able to reproduce bug with only drupal core + webform, ctools, & views. Changing status back to Normal.
I'm still applying this patch to 7.x-4.21, but if the recommended approach for adding the
novalidateattribute is to use a custom module, we should mark this issue asclosed (won't fix), and those of us using the patch should adapt our sites appropriately.Comment #36
liam morland