Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
forms system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Sep 2009 at 10:39 UTC
Updated:
29 Jul 2014 at 18:27 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
effulgentsia commentedYeah, would have been nice. D8 material now.
Comment #2
chx commentedIf we would pass the form by reference all across validate then we could set the error on the form itself too. Needs to be done in form_state too so we have a cumulative list without iterating the form to display the errors themselves but if we do it on the form elements then they are self-contained to be erroneus and much easier to theme as such.
Comment #3
larowlansubs
Comment #4
sunI agree with @chx, ideally we store it in both $form and $form_state, whereas $form_state should contain the complete list of errors, and the element in $form should only hold declarative properties.
To think a bit ahead of time: In #742344: Allow forms to set custom validation error messages on required fields, I already attempted to introduce a
$element['#required_error']property (holding a custom required error message for #required elements). So ideally, we'll try to think a bit of other changes in the future, especially with regard to the $form element properties; e.g. an#error*element property namespace, so we don't end up with a shitload of different#has_error,#errormessage, ... properties. (btw, the internal form validation properties could use a similar name(space) overhaul)Also, we need to retain the currently existing edge-case functionality of
''(empty string) as parents, essentially filing an error against the entire form.custom][parents, allowing to mark an entire form section as erroneous.Comment #5
casey commentedAPI changes:
Needs work:
Comment #6
sunThanks! Looks pretty good already. Can you roll further patches with
-pto include more context info in the diff, please?Comment #7
chx commentedHuh I am sorry I butt in after a 100kb+ patch but there was no previous patch so I couldn't before
That's hideous. Can't we do a
form_error($form['form_token']instead? The very issue title is to get rid of this function completely.Comment #8
casey commentedUpdate:
Issues:
Comment #9
casey commentedArr forgot local commit
Update:
Comment #11
casey commented#1180662: Don't call form_set_error(), form_get_errors() and alikes in functions that aren't necessarily form related
Comment #12
joachim commentedRather than call what is now a 3-param function, wouldn't it be easier to do this bit in validation handlers, and then have the Form API look at these after all the validation handlers have been called?
0 days to next Drupal core point release.
Comment #13
tim.plunkettchx pointed me to this issue while I was working on #2131851: Form errors must be specific to a form and not a global, the code base has changed drastically, but the $elements['#errors'] approach really really helped.
They are duplicates of each other, but I don't really know if it's okay to close this much older one...
Comment #14
tim.plunkettI think I've sorted it in #2131851: Form errors must be specific to a form and not a global