Normal HTML checkboxes only submit their value when they are checked, but
sometimes you want a value to be submitted even if the box is unchecked.
This offers an alternative that will submit a value depending on the checked
status, customizable with yes_value
and no_value
.
This creates an #always_checkbox{}
element for the Nitrogen Web
Framework
Add it as a rebar dependency by adding into the deps section of rebar.config:
{always_checkbox, "", {git, "git://github.com/choptastic/always_checkbox.git", {branch, master}}}
Run make
in your Application. The rest should be automatic.
Run the following at the command line:
./rebar get-deps
./rebar compile
Then add the following includes into any module requiring the form
-include_lib("always_checkbox/include/records.hrl").
#always_checkbox{
postback_id=my_checkbox,
yes_value="Yes it's checked",
no_value="Not checked",
checked=true
}.
Note that this plugin works by using a hidden input to store the intended values. That hidden input id, which is the one you will wf:q(...), is set with the postback_id parameter.
Copyright (c) 2014, Jesse Gumm (@jessegumm)
MIT License