Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/choptastic/always_checkbox

An `#always_checkbox{}` element for Nitrogen
https://github.com/choptastic/always_checkbox

Last synced: 21 days ago
JSON representation

An `#always_checkbox{}` element for Nitrogen

Awesome Lists containing this project

README

        

# 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](http://nitrogenproject.com)

## Installing into a Nitrogen Application

Add it as a rebar dependency by adding into the deps section of rebar.config:

```erlang
{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:

```shell
./rebar get-deps
./rebar compile
```

Then add the following includes into any module requiring the form

```erlang
-include_lib("always_checkbox/include/records.hrl").
```

## Usage

```erlang
#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](http://sigma-star.com/page/jesse)
([@jessegumm](http://twitter.com/jessegumm))

MIT License