cfpb/cms-toolkit — pull request #11 by gboone (2014-07-23 15:26:29+00:00)
Title: Js for formset

This is a fairly large restructuring of the link field type that allows a child plugin writer to specify how many fields should be shown by default. Previously, declaring a link field could be done using the 'count' key inside the `params` array like so:
```
$this->fields = array(
'related_link' => array(
'slug' => 'related_link',
'type' => 'link',
'params' => array(
'count' => 5,
),
'meta_key' => 'related_link',
'howto' => 'The link will be saved as an array where [0] is the url and [1] is the text.',
),
);
```

Now authors can optionally use the `init_num_forms` and `max_num_forms` keys to determine how many link fields show show on initial page load, and how many may be added. This looks like this:
```
$this->fields = array(
'watchroom_data' => array(
'slug' => 'related_link',
'type' => 'link',
'params' => array(
'init_num_forms' => 2,
'max_num_forms' => 10,
),
'meta_key' => 'watchroom_data',
'howto' => 'The link will be saved as an array where [0] is the url and [1] is the text.',
)
);
```

In this example we will show 2 forms on initial pageload and use javascript to add and remove up to 10 fields from the edit screen.

Not included here, but slated for a future PR, is validation for relative _and_ absolute URLS on the URL side of these fields.