Problem/Motivation
Elements of the type webform-buttons are not rendered as buttons, but as radio-boxes. I am observing this in the Elements Example Page found at /form/example-elements.
Proposed resolution
I found the javascript at /modules/webform/js/webform.element.buttons.js would not replace these elements.
The selector ($(context).find('fieldset.js-webform-buttons div.fieldset-wrapper').once('webform-buttons').each(…)) used for finding the buttons resulted in an empty set.
When I change the selector to $(context).find('.js-webform-buttons,.js-webform-buttons-other').once('webform-buttons').each(…) the buttons will render as expected.
Remaining tasks
Please compare the used selectors. Are they a wise choice? Is it the right place to fix this issue, or does it maybe need the div.fieldset-wrapper from the former selector code?
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | button_elements-2849799-11.patch | 2.53 KB | jrockowitz |
| #8 | button_elements-2849799-7.patch | 0 bytes | jrockowitz |
| #6 | button_elements-2849799-6.patch | 659 bytes | jrockowitz |
| #3 | fix_broken_selector_2.patch | 2.26 KB | propercroc |
| fix_broken_selector.patch | 1.09 KB | propercroc |
Comments
Comment #2
propercroc commentedWhen I try to style the elements, I miss:
- a label with the elements name
- a
div.form-grouparound the elementIn other words:
Comment #3
propercroc commentedI found a better selector that conserves the original title of the item.
I still think the structure from my last comment would be more helpful to style. But I'd gladly listen about the upside of having the given markup.
Comment #4
propercroc commentedIn the Example Elements Page, why does webform-buttons have a
div.panel-heading div.panel-titlewhile webform-buttons-other haslabel.control-labelas markup for the elements label?Comment #5
jrockowitz commentedThis makes perfect sense.
.panel-body is too specific of selector
Comment #6
jrockowitz commentedMaybe we only need to target .js-webform-buttons.
@ProperCroc you patch does not apply, try execute the diff from within the webform modules directory.
Also, to get the patch tested you need to set this ticket's status to 'Needs review'
Comment #7
jrockowitz commentedMy previous patch delete the form element's label.
That was a lot trickier to fix.
I had to use a jQuery.fn.commonAncestor plugin.
Please review.
Comment #8
jrockowitz commentedComment #11
jrockowitz commentedDuh! I uploaded an empty patch. I had to go back to my standard GitFlow, so there is now a branch available for this ticket.
Comment #13
jrockowitz commentedPlease review and test the latest dev release.
Comment #15
gambryFrom #6:
Not including .js-webform-buttons-other, when using 'Buttons other' element type I get a javascript error due
jQuery('body').find('.js-webform-buttons [type="radio"]').lenghtbeing 0.TypeError: parents[0] is undefined
jQuery.fn.commonAncestor() jquery.common_ancestor.js:27
Drupal.behaviors.webformButtons.attach() webform.element.buttons.js:17
Drupal.attachBehaviors() drupal.js:168
[..]
Comment #16
jrockowitz commentedPlease try the latest dev release. I removed the jquery.common_ancestor.js library and went back to just
$(context).find('.js-webform-buttons .form-radios, .js-webform-buttons.form-radios')Comment #17
gambryI will, thanks!
Comment #18
propercroc commentedJust tried with webform-8.x-5.x-dev.tar.gz –
Works fine for me :) Thank you!