Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
i'd need to add some descriptions for single options in checkboxes or radios elements. Just found out it is possible in forms thanks to this: https://www.drupal.org/node/2531656.
i read this was already suggested and closed https://www.drupal.org/node/1721998, but since the 8 version of Webform has changed a lot of things, well... why not trying again?
i think i can help with patches and code, would just like to have a couple hints on where to start from... Could anyone give me suggestions?
thanks!
Comment | File | Size | Author |
---|---|---|---|
#11 | options_descriptions-2910504-11.patch | 144.69 KB | jrockowitz |
| |||
#8 | options_descriptions-2910504-8.patch | 141.28 KB | jrockowitz |
| |||
#6 | options_descriptions-2910504-6.patch | 141.28 KB | jrockowitz |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThis is going to be really difficult to fully support. I am not exactly sure where to begin.
Comment #3
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI am so tempted to suggest we add a description delimiter that automatically generates a checkbox/radio description.
This is a "hacky" solution but very easy to implement and support.
...then we could take it a step further and support the help tooltip (ie '?' ) using a different delimiter.
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedThe \Drupal\webform\Element\WebformElementOptions could be extended to support option descriptions.
I am leaning toward the YAML syntax being...
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #11
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #13
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch. Adding descriptions or help text to checkboxes and radios is now fully supported. Please download the latest dev release to review.
Comment #15
joey-santiago CreditAttribution: joey-santiago at Siili Solutions commentedThanks a lot, works perfectly!
as i wanted them to go on a new line in stead of being "immersed" in the title text, i went this way:
1: added an element to the form_element_label.html.twig
2: used template_preprocess_form_element_label() to split the title by WebformOptionsHelper::DESCRIPTION_DELIMITER and extract my description
hope it can help others :)