-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation error for date_popup is missing the element title #6274
Comments
I can confirm this issue. A possible solution is to assign the title to As I was testing this, I found a fatal error for date fields that use a popup, when the date is left blank. I'll create a separate issue. |
I've made the change you suggested @argiepiano, and that fixes this problem. But in testing, I found another related problem in validation for The at-fault code is also in
We can fix this by adding space to that first
But wait. Oh, and the title is also missing for a |
The fix for the title for blank entries for |
Here's a form snippet for testing all three at once:
With the changes described above, here's the result with blank entries: And here's the result with bogus entries: PR to follow. |
@bugfolder thanks so much for providing this PR. I've tested, and it works for me. Code LGTM. There are a couple of things I've noticed, which are unrelated to this fix and were present before patching:
I'll submit two issues for this. |
Thanks @argiepiano and @bugfolder! I merged backdrop/backdrop#4560 into 1.x and 1.26.x. |
Description of the bug
For the
date_popup
element, when a required date is empty, the validation error is missing the element title.Steps To Reproduce
To reproduce the behavior:
Add this element to a form.
Leave the field blank and submit it, which should create a form error for the missing
#required
value.Actual behavior
The error message is "A valid date is required for .".
Expected behavior
The error message should be "A valid date is required for My date.".
Additional information
The error message is generated in function
date_popup_validate()
, via this bit of code:The variable
$label
is set via this code earlier in the function:So in this example,
$label
is set from the#title
property. However, by the time this code is reached,#title
has already been set toNULL
.This is because
date_popup_element_process()
creates childdate
and/ortime
parts, sets their title(s) from$element['#title']
, and then clears$element['#title']
(lines 1013–1014 of date.elements.inc):So it looks like either the element
#title
should not be cleared here so it remains available to the validation error, or the validation code should check for the child element title(s) when creating the validation error message.The text was updated successfully, but these errors were encountered: