?
avatar patrick-hertling
patrick-hertling
21 Feb 2014

<field name="myname" type="checkbox" value="12" label="mylabel" />

If we load the form input the default value of 1 would load instead of 12.

avatar patrick-hertling patrick-hertling - open - 21 Feb 2014
avatar Achal-Aggarwal
Achal-Aggarwal - comment - 21 Feb 2014

yes it is happening. I have a fix. Making a tracker and PR for it.

avatar Bakual
Bakual - comment - 21 Feb 2014

There are two things with this "issue":
First you usually don't set an actual value in the XML. You can use default to set a default value, which is probably what you want?
Second, default values don't work for checkboxes due to the way a checkbox work in HTML.

avatar patrick-hertling
patrick-hertling - comment - 22 Feb 2014

@Bakual You are probably right, but then the value atribute should be removed from formFieldCheckbox. And even though, If default="<value>" is selected, the checkbox is automatically checked which is not always wanted.
I noticed becouse I updated a site from 3.1.5 to 3.2.2 and Javascript started to fail. At 3.1.5 it was working as expected.

avatar Bakual
Bakual - comment - 22 Feb 2014

Yep, that's why I said default values don't work for checkboxes. That's due to the way HTML checkboxes work.

The value attribute would actually be used to assign a value to the checkbox which is sent when it's enabled. Similar to an option in a select list. It doesn't say if it's enabled or not, but what value is sent together with it's name when checked. This does indeed not work currently. But then, usually you don't need this anyway as we would just set it to 1 in most cases and check the presence (not the value) of the checkbox in POST.
But it's an issue which someone could fix :smile:
Also, docpage is found here: http://docs.joomla.org/Checkbox_form_field_type

avatar brianteeman
brianteeman - comment - 23 Jul 2014

Closing in favour of the referenced trcker so that comments only take place in one place

avatar brianteeman brianteeman - change - 23 Jul 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-07-23 15:09:42
avatar brianteeman brianteeman - close - 23 Jul 2014
avatar zero-24 zero-24 - close - 23 Jul 2014
avatar zero-24 zero-24 - change - 7 Jul 2015
Labels Added: ?

Add a Comment

Login with GitHub to post a comment