choptastic / always_checkbox

An `#always_checkbox{}` element for Nitrogen

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

always_checkbox

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

Installing into a Nitrogen Application

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}}}

Using Nitrogen's built-in plugin installer (Requires Nitrogen 2.2.0)

Run make in your Application. The rest should be automatic.

Manual Installation (Nitrogen Pre-2.2.0)

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").

Usage

	#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.

License

Copyright (c) 2014, Jesse Gumm (@jessegumm)

MIT License

About

An `#always_checkbox{}` element for Nitrogen


Languages

Language:Erlang 100.0%