Closed (outdated)
Project:
Drupal core
Version:
6.x-dev
Component:
forms system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Sep 2012 at 08:58 UTC
Updated:
2 Mar 2016 at 22:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
boobaaHere they come.
Comment #2
boobaaMeh, forgot to NR.
Comment #3
chx commentedForm validation does not fail, which means a form with a #required element which has no #title nor value can be submitted.
Nope. Form validation fails and the submit handler does not run. This can easily be seen by adding an + $this->assertNoRaw("The form_test_validate_required_form_no_title form was submitted successfully.", 'Validation form submitted successfully.');
to the test only patch after the first drupalPost.
Comment #4
boobaaUpdated patches according to @chx's instructions.
Comment #5
boobaaThe bug is present in 8.x as well; here are the patches.
Comment #7
boobaaThat failing test seems to be totally unrelated for me. Does anybody have a clue about that?
Comment #8
boobaa#5: core-1785436-5-required-no-title-test-only-D8.patch queued for re-testing.
Comment #9
boobaa#5: core-1785436-5-required-no-title-test-and-fix-D8.patch queued for re-testing.
Comment #10
chx commentedyou do not use this $errors variable and also assertFieldByXPath() is the exact same as just xpath() if you call it with a NULL, but a little later in the code there's the call with FALSE -- so let's do that here as well. And let's get rid of $errors as it is not used.
Other than that, this is ready. Typically we would verify the nullity of a value with isset() but as it is not a variable the !== NULL is fine here.
Comment #11
boobaaUpdated the patches according to #10, 7.x comes first.
Comment #12
boobaaThen 8.x.
Comment #13
chx commentedThis is good to go IMO.
Comment #14
chx commentedComment #15
catchThanks. Committed/pushed to 8.x.
Looks like this needs a 7.x backport?
Comment #16
boobaaI do know it's not a good idea to mark my own issue as RTBC, but this time it's the proper way, I think: D7 patches are available in #11 already, and @chx marked them RTBC in #13. I have even checked now that the D7 patch can still be applied cleanly.
Comment #17
webchickHm. This represents a behaviour change. I'd like to run this past David first. I could see it cause seemingly random issues to crop up in contrib/custom modules, perhaps a valid use case of which might be programmatically setting #required fields behind the scenes. Then again, it seems like it's probably just exposing what ought to be happening anyway. So... yeah. Would love to get David's thoughts before commit. :)
Comment #18
David_Rothstein commentedAs far as I can see, this should be safe; it makes the HTML output correctly reflect the form validation that the form API already did.
Now, watch us be totally wrong and this turn out to be the patch that breaks all of Drupal :)
In the hopes that that's not the case, I committed this to 7.x - thanks! http://drupalcode.org/project/drupal.git/commit/01f18eb (But to be safe, I'm adding this to CHANGELOG.txt and to the release notes also.)
Actually, it seems pretty odd to me that we don't display some kind of error message in this case also (in addition to the red border around the form element) but I guess that's for some other issue to solve.
Comment #19
David_Rothstein commentedComment #20
David_Rothstein commentedIn theory this could be backported, although I'm not sure it's really worth it at this point.
Comment #21
mrharolda commentedI found a regression with views and required exposed filters caused by this patch. In #1877678: Exposed filter gets error class without submitting it comment #6 there's a simple view to reproduce this.
Changing the patched line
to the Drupal 7.16 version (pre 01f18eb540c968d1bfae7def22de558bdc208c17)
doesn't add the error class on this unsubmitted and thus "errorless" form.
A var_dump() of
form_get_error($element)results instring(0) "", and not NULL.Comment #22
mrharolda commentedHmmm... Further investigation points to this piece of code in
views/plugins/views_plugin_exposed_form.inc->render_exposed_form()In this case
'always_process' => TRUEtriggers form validation, which < Drupal 7.17 did throw an error, but without the error class. I now believe the patch from this issue reveiled the error in the views exposed filter plugin instead of causing it ...Marking it as 6.x/patch again, sorry for the noise!
Comment #22.0
mrharolda commentedvalidation has no problems