Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Checkbox for boolean values

I am trying to use Tag::checkField to check one bool value in search, but if i dont click the box, it is not registered as 0 in search. If i click it, 1 is registered in search. Any suggestions? I tried few paramaters but i havend succeeded.

echo Tag::checkField(array("active", "value" => "1"));

edited Jun '14


Checkbox are sending in POST only when is checked. In Liftweb (Web Framework in Scala) I meet this solution for this:

echo Tag::hiddenField(array("active", "value" => "0"));
echo Tag::checkField(array("active", "value" => "1"));

This code produces hidden field with default value. The hidden field should be before checkbox. If your checkbox is checked the hidden value will be overridden.


Good idea, i will try and let you know if it worked in all scenarios :)