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.
1.I have 5 check boxes inside a fieldset which are to be selected by the user tp submit the form?
How do I achieve this?
2. Is there a way to freeze the by default selected check box -menaing user should not be given the choice to deselect it
3. Alternatively I tried this:
I have 5 check boxes inside the fieldset and the keys of thoses check boxes are 0,1,2,3,4 so I entered these values in default field but only four checkboxes (1,2,3,4) are selected by default and not the first checkbox whose Key is '0' - Any comments please
Any help is appreciated.
Thanks in advance
Comments
Comment #1
quicksketchHi there, I'm not completely understanding your questions.
You mean the user must check *all five* checkboxes in order to submit the form? So marking the field required doesn't cut it because only one box is required currently?
You can do this through hook_form_alter() or in the theme layer using a webform-form-[nid].tpl.php file (see THEMING.txt). There isn't a built-in way to do this.
I can't confirm this problem in 7.x-3.18. I set up three checkboxes with the values:
And the default value of
0,1,2
. Upon viewing the form, all 3 checkboxes were selected by default as they are supposed to be.Comment #2
Akshita CreditAttribution: Akshita commented1.I have 5 check boxes inside a fieldset which are to be selected by the user tp submit the form?
------- YES
2. Is there a way to freeze the by default selected check box -menaing user should not be given the choice to deselect it
You can do this through hook_form_alter() or in the theme layer using a webform-form-[nid].tpl.php file (see THEMING.txt). There isn't a built-in way to do this. OK (will try)
I have 5 check boxes inside the fieldset and the keys of thoses check boxes are 0,1,2,3,4 so I entered these values in default field but only four checkboxes (1,2,3,4) are selected by default and not the first checkbox whose Key is '0' - Any comments please
Here is the view source though entered manually in the default field 0,1,2,3,4 -
Comment #3
Akshita CreditAttribution: Akshita commented@quicksketch
Any check box whose value is "0" then it is never selected by default though set manually no matter the checkbox is inside or outside the fieldset.
To resolve my issue - I simply changed the value of my checkbox whose value is "0" to someother value and now all my 5 checkboxes are seleted by default.
Please close this thread.
Thanks a lot
Revathi
Comment #4
quicksketch