1 (edited by cambell 08/05/2016 09:21:39 am)

Topic: Unchecked checkbox form value not set in Ajax call

While writing a module I found that the checkbox value is not set for unchecked checkboxes.  I propose a fix to js/utils.js such that unchecked checkboxes come through to php with a value of ''.

A pull request is here:

https://github.com/FrontAccountingERP/FA/pull/15

Cambell https://github.com/cambell-prince

Re: Unchecked checkbox form value not set in Ajax call

Well, this is just how HTML POST method works in browsers for checkbox type input field (not ticked checkbox is ignored).  Changing it will lead to problems in forms which just look for POST variable existence,  which is standard way of dealing with checkbox controls.

Janusz

Re: Unchecked checkbox form value not set in Ajax call

Assuming that folk use the check_value(...) function in ui_input.inc all would be fine.  Without this mod requires that all checkboxes be explicitly handled via intentional use of the check_value function or similar.  This change makes the humble checkbox handling the same as other input controls which have value.

I'll be keeping this functionality in my fork.

Cambell https://github.com/cambell-prince

Re: Unchecked checkbox form value not set in Ajax call

Thanks @cambell and @itronics.

Lesson: New modules and code modifiers should keep this fact in mind when using / dealing with checkboxes - in FA, use check_value() before using it....