Problem/Motivation
uswds_preprocess_form_element() does not properly check for the existence of a form element's id key before trying to access it.
Steps to reproduce
- Install the webform module
- Create a webform
- Add a text field with a maximum word length
- Save and browse to the form
- Attempt to submit the form with a value that exceeds the maximum word length
Expected: A validation message appears
Actual: A validation message appears, but also you get:
Warning: Undefined array key "id" in uswds_preprocess_form_element() (line 32 of themes/contrib/uswds/preprocess/element/form_element.preprocess.inc).
Proposed resolution
The line in question is:
$variables['error_id'] = $variables['element']['#attributes']['id'];
But as far as I can tell the
error_id value is never used. I believe the correct solution is to simply remove this line.
Remaining tasks
None
User interface changes
None
API changes
None
Data model changes
None
Comments
Comment #2
joshf commentedThis patch removes the erroring line entirely. If it turns out this is actually used for something, we should probably just add a default to NULL.
Comment #3
joshf commentedComment #4
joshf commentedTurns out this is actually fixed in the latest dev.