Anahkiasen/former — pull request #302 by claar (2014-04-12 03:01:53+00:00)
Title: Fix grouped checkbox repopulating from POST and the Populator.

This is my second attempt at #223 / #220 / #35, this time with more care not to break existing code.

This PR fixes repopulating grouped checkboxes from POST, and also enables the following repopulate syntax:
```php
// Numerically indexed checkboxes -- "Checkbox 1" will be checked:
Former::populate(array('foo' => array(0 /* name */=> 0 /* value */)));
Former::checkboxes('foo[]')->checkboxes('Checkbox 1', 'Checkbox 2');

// string indexed checkboxes -- "Checkbox 1" will be checked:
Former::populate(array('foo' => array('name1' => 'value1')));
Former::checkboxes('foo[]')->checkboxes(
'Checkbox 1' => array('name' => 'foo[name1]', 'value' => 'value1'),
'Checkbox 2' => array('name' => 'foo[name2]', 'value' => 'value2'),
);

// Grouping using the "chain" syntax is also identically supported:
Former::checkboxes('foo')->grouped()->checkboxes('Checkbox 1', 'Checkbox 2');
```

Two things I did not do in this PR, that I will open separate pull requests for:
* In my opinion, the values for grouped checkboxes should be 1 by default, not 0/1/2/etc.
* It would be handy to be able to populate using IDs instead of names/index, e.g. `Former::populate(array('foo_0' => 1))`

I didn't combine these since I'm not sure what caused #223 to break existing code.

Note that Travis tests won't pass on this until #301 lands.