?
avatar Bakual
Bakual
7 Nov 2016

Steps to reproduce the issue

  1. Create a custom field of the type checkboxes and assign two options, one of them with a 0 value. Eg: yesno
  2. Select only the 0 value ("No" in my example) and save
  3. Reopen the form and check the value. Check the item in frontend.

Expected result

The selected 0 value is shown in both places

Actual result

The selected 0 value is ignored in both places

Additional comments

This is an issue with how com_fields sets up the fields.
If I specify a checkboxes field in the form XML with the same options, it works fine. So it's not the JFormFieldCheckboxes that is buggy.
When debuging I saw that when the form is defined in the XML, the value in https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/form/fields/checkboxes.php#L153 is an array (even with only one option) and the $hasValue passes. However if it is coming from com_fields, the value is a string if it's only one selected option and thus the check fails.

Now we could adjust the formfield to take care of strings as well, but I don't know the side effects as checkboxes are really a strange thing to handle.

I'd prefer to fix it in com_fields, but I haven't found yet where we could do it.
Also it may be related to the $forceMultiple property that is set in the checkboxes field. Maybe com_fields need to read that one and act accordingly.

avatar Bakual Bakual - open - 7 Nov 2016
avatar joomla-cms-bot joomla-cms-bot - change - 7 Nov 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 10 Nov 2016
Category com_fields
avatar laoneo
laoneo - comment - 14 Nov 2016

Added a callback to the field to prepare the value in #12886.

avatar laoneo
laoneo - comment - 22 Nov 2016

Can be closed as we have a PR #12886.

avatar Bakual Bakual - change - 22 Nov 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-11-22 09:24:58
Closed_By Bakual
avatar Bakual Bakual - close - 22 Nov 2016

Add a Comment

Login with GitHub to post a comment