Skip to content

Commit

Permalink
Update docs on readme
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeelia committed Nov 18, 2018
1 parent 9f6a353 commit f1f0023
Show file tree
Hide file tree
Showing 4 changed files with 1,592 additions and 15 deletions.
51 changes: 40 additions & 11 deletions README.md
@@ -1,8 +1,8 @@
# Contact Form 7 - Repeatable Fields #
**Contributors:** [felipeelia](https://profiles.wordpress.org/felipeelia)
**Tags:** contact form 7, cf7
**Tags:** contact form 7, cf7, repeater, repeatable
**Requires at least:** 4.6
**Tested up to:** 4.9.4
**Tested up to:** 4.9.8
**Requires PHP:** 5.3
**Stable tag:** 1.1
**License:** GPLv2 or later
Expand Down Expand Up @@ -68,9 +68,9 @@ The available filters are:
Filters the add button attributes.

Parameters:
- $attributes: Array of attributes for the add button. Keys:
- `additional_classes`: css class(es) to add to the button
- `text`: text used for the button
* $attributes: Array of attributes for the add button. Keys:
* `additional_classes`: css class(es) to add to the button
* `text`: text used for the button

Return value: array of button attributes

Expand All @@ -79,7 +79,7 @@ Return value: array of button attributes
Filters the add button HTML.

Parameters:
- $html: Default add button HTML
* $html: Default add button HTML

Return value: button HTML

Expand All @@ -88,9 +88,9 @@ Return value: button HTML
Filters the remove button attributes.

Parameters:
- $attributes: Array of attributes for the remove button. Keys:
- `additional_classes`: css class(es) to add to the button
- `text`: text used for the button
* $attributes: Array of attributes for the remove button. Keys:
* `additional_classes`: css class(es) to add to the button
* `text`: text used for the button

Return value: array of button attributes

Expand All @@ -99,7 +99,7 @@ Return value: array of button attributes
Filters the remove button HTML.

Parameters:
- $html: Default remove button HTML
* $html: Default remove button HTML

Return value: button HTML

Expand All @@ -112,7 +112,36 @@ If you like it, a review is appreciated :)

### Can I change the add/remove buttons? ###

* Yes. You can use `wpcf7_field_group_add_button_atts`, `wpcf7_field_group_add_button`, `wpcf7_field_group_remove_button_atts`, and `wpcf7_field_group_remove_button` filters. It'll be better documented soon.
Yes. You can use `wpcf7_field_group_add_button_atts`, `wpcf7_field_group_add_button`, `wpcf7_field_group_remove_button_atts`, and `wpcf7_field_group_remove_button` filters, as shown above. Props to @berniegp.

### How can I display the group index number in the form? ###

You'll have to use the `wpcf7-field-groups/change` jQuery event.

In the Mail tab, add an element to hold the group index. In this example, it'll be a `<span>` with the `group-index` class:
~~~
[field_group emails id="emails-groups" tabindex:1]
<p>Group #<span class="group-index"></span></p>
<label>Your Email (required)[email* your-email]</label>
[radio your-radio use_label_element default:1 "radio 1" "radio 2" "radio 3"]
[select* your-menu include_blank "option1" "option 2"]
[checkbox* your-checkbox "check 1" "check 2"]
[/field_group]
~~~

And then you’ll have to add this to your JavaScript code:
~~~
jQuery( function( $ ) {
$( '.wpcf7-field-groups' ).on( 'wpcf7-field-groups/change', function() {
var $groups = $( this ).find( '.group-index' );
$groups.each( function() {
$( this ).text( $groups.index( this ) + 1 );
} );
} ).trigger( 'wpcf7-field-groups/change' );
} );
~~~

You can add that JS through your theme OR use some plugin like [Simple Custom CSS and JS](https://wordpress.org/plugins/custom-css-js/).

## Changelog ##

Expand Down

0 comments on commit f1f0023

Please sign in to comment.