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

quicksketch’s picture

Hi there, I'm not completely understanding your questions.

1.I have 5 check boxes inside a fieldset which are to be selected by the user tp submit the form?

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?

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.

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

I can't confirm this problem in 7.x-3.18. I set up three checkboxes with the values:

0|zero
1|one
2|two

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.

Akshita’s picture

1.I have 5 check boxes inside a fieldset which are to be selected by the user tp submit the form?

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?

------- 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

I am not sure how this is working for you. -I tried again same issue the first option is never selected by default -(Note : all the 5 check boxes are inside the fieldset)


Even if the checkboxes are not inside the fieldset - the first check box is never selected by default - please do the needful.

Here is the view source though entered manually in the default field 0,1,2,3,4 -

first one is never selected
<div class="form-item form-type-checkbox form-item-submitted-check-each-box-understanding-0">
<input id="edit-submitted-check-each-box-understanding-1" class="form-checkbox" type="checkbox" value="0" name="submitted[check_each_box][understanding][0]">events=Object { change=[1], click=[1], blur=[1], more...}handle=function()
<label class="option" for="edit-submitted-check-each-box-understanding-1">hello1 </label>
</div>
<div class="form-item form-type-checkbox form-item-submitted-check-each-box-understanding-1">
<input id="edit-submitted-check-each-box-understanding-2" class="form-checkbox" type="checkbox" checked="checked" value="1" name="submitted[check_each_box][understanding][1]">events=Object { change=[1], click=[1], blur=[1], more...}handle=function()
<label class="option" for="edit-submitted-check-each-box-understanding-2">hello2 </label>
</div>
<div class="form-item form-type-checkbox form-item-submitted-check-each-box-understanding-2">
<input id="edit-submitted-check-each-box-understanding-3" class="form-checkbox" type="checkbox" checked="checked" value="2" name="submitted[check_each_box][understanding][2]">events=Object { change=[1], click=[1], blur=[1], more...}handle=function()
<label class="option" for="edit-submitted-check-each-box-understanding-3">hello3 </label>
</div>
<div class="form-item form-type-checkbox form-item-submitted-check-each-box-understanding-3">
<input id="edit-submitted-check-each-box-understanding-4" class="form-checkbox" type="checkbox" checked="checked" value="3" name="submitted[check_each_box][understanding][3]">events=Object { change=[1], click=[1], blur=[1], more...}handle=function()
<label class="option" for="edit-submitted-check-each-box-understanding-4">hello4 </label>
</div>
<div class="form-item form-type-checkbox form-item-submitted-check-each-box-understanding-4">
<input id="edit-submitted-check-each-box-understanding-5" class="form-checkbox" type="checkbox" checked="checked" value="4" name="submitted[check_each_box][understanding][4]">events=Object { change=[1], click=[1], blur=[1], more...}handle=function()
<label class="option" for="edit-submitted-check-each-box-understanding-5">hello5 </label>
</div>
</div>
Akshita’s picture

@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

quicksketch’s picture

Status: Active » Closed (fixed)