Closed (fixed)
Project:
Webform
Version:
7.x-4.x-dev
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Jun 2014 at 14:30 UTC
Updated:
15 Mar 2015 at 20:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
danchadwick commented@quicksketch - Why are the ids intentionally removed? Do we still need to do this?
@aprogs - if you are using hook_form_alter to add your #states, why not remove the pre-render that serves to remove the ids?
Comment #2
aprogs commentedHi @DanChadwick,
I guess that there are weighty reasons for removing id attribute. So, I decided to ask about it here.
Thanks
Comment #3
quicksketchThe IDs are removed as part of an overall effort to reduce the use of IDs and increase the use of classes. Buttons in particular were a problem because if you had multiple forms on the page, the IDs of the submit buttons would keep changing out from under you, making any CSS that targeted them difficult to predict.
Restoring the IDs shouldn't cause any problems other than those we had before. It hadn't occurred to me that someone would want to use #states to hide/show the buttons themselves.
I'd suggest one of two approaches to fix this problem for your use-case:
1) In your form_alter(), remove the "webform_pre_render_remove_id" callback from the button #pre_render array.
2) Or perhaps just don't use #states and add your own JS.
We could also potentially put a fix in
webform_pre_render_remove_idthat checks if #states is set, and if so, leaves the IDs in place.Comment #4
danchadwick commentedI liked quicksketch's third option: ids are only removed if there are no #states defined. Tested and applied to 7.x-4.x and 8.x.
Comment #6
aprogs commentedThanks for paying attention to this issue.
Comment #8
danchadwick commented