Skip to content
This repository has been archived by the owner on Jan 13, 2018. It is now read-only.

Adding functionality and fixing a few bugs #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
**[Looking for contributors!](https://github.com/kodie/gravityforms-repeater/issues/75)**

![](/assets/icon-256x256.png?raw=true)
# Gravity Forms Repeater Add-On
A Gravity Forms add-on that allows specified groups of fields to be repeated by the user.
Expand Down Expand Up @@ -57,29 +55,29 @@ You can use Javascript to manipulate the repeater.
* repeaterChildId works the same way and depends on how many times the repeater has been repeated.
* These functions will not allow you to repeat more than the set max and unrepeat more than the set min.
#
```javascript
// Repeats the repeater once.
```
gfRepeater_repeatRepeater(formId, repeaterId);
Repeats the repeater once.
```
```
```javascript
// Un-repeats the repeater once. repeaterChildId is optional.
gfRepeater_unrepeatRepeater(formId, repeaterId, repeaterChildId);
Un-repeats the repeater once. repeaterChildId is optional.
```
```
```javascript
// Repeats the repeater a number of times.
gfRepeater_repeatRepeaterTimes(formId, repeaterId, timesX);
Repeats the repeater a number of times.
```
```
```javascript
// UnRepeats the repeater a number of times.
gfRepeater_unrepeatRepeaterTimes(formId, repeaterId, timesX);
UnRepeats the repeater a number of times.
```
```
```javascript
// Repeats or unrepeats the repeater to get it to whatever timesX is.
gfRepeater_setRepeater(formId, repeaterId, timesX);
Repeats or unrepeats the repeater to get it to whatever timesX is.
```
```
```javascript
// Selects an element depending on the variables passed. All variables are optional besides formId. inputId also accepts '*' to select all inputs.
gfRepeater_select(formId, repeaterId, repeatId, childId, inputId);
Selects an element depending on the variables passed. All variables are optional besides formId. inputId also accepts '*' to select all inputs.
```

##### Triggers
Expand All @@ -105,8 +103,6 @@ gfRepeater_repeaters
['paremCount'] - The highest field ID that has had their prepopulate paremeter set.
['tabIndex'] - The tabindex that was assigned to the repeater start field and will be assigned to all children.
['inputData'] - Contains an array with all of the input names in the repeater.
['startIdNum'] - ID Number of the repeater start field.
['endIdNum'] - ID Number of the repeater end field.
['settings'] - Contains the different settings that are set in the form editor.
['start'] - The number of times the repeater should be repeated when the form is loaded.
['min'] - The minimum number of times the repeater can be repeated.
Expand Down Expand Up @@ -137,15 +133,15 @@ gfRepeater_repeaters

##### Usage Examples
Repeat the repeater a number of times depending on the value of a drop down field:
```javascript
```
jQuery('#gform_6 #input_6_7').change(function(){
var attendees = jQuery(this).val();
gfRepeater_setRepeater(6, 1, attendees);
});
```

Change the value of a field if the repeater is repeated or un-repeated:
```javascript
```
jQuery('#gform_9').on('gform_repeater_after_repeat gform_repeater_after_unrepeat', function(event, repeaterId, repeatId){
if (repeaterId == 1) {
var repeatCount = gfRepeater_repeaters[9][1]['data']['repeatCount'];
Expand Down Expand Up @@ -241,4 +237,4 @@ and you're good to go!

### Installation
1. Upload the `repeater-add-on-for-gravity-forms` folder to the `/wp-content/plugins/` directory.
1. Activate the plugin through the 'Plugins' menu in WordPress.
1. Activate the plugin through the 'Plugins' menu in WordPress.
29 changes: 7 additions & 22 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
v1.1.0 (TBA)
- Fixed bug where sometimes a javascript error would occur in the form editor when trying to save a form after deleting a repeater.
- Fixed bug where sometimes a 'Undefined Index "conditionalLogic"' error is shown when submitting a form.
- Fixed bug where repeated field values would be cleared if on a multipage form. (Issue #21)
- Fixed bug where a PHP error is shown when viewing an entry's details if no repeater child fields have been filled out. (Issue #24) (Thanks @WebImage!)
- Fixed bug where repeated field tab indexes would be set to "NaN" if tab indexes are disabled. (Issue #28)
- Fixed bug where javascript erros would occur if there was more than one form on the same page.
- Fixed bug where javascript functions would try to do things on other forms on the same page even if they didn't have a repeater field.
- Fixed repeater start pre-populate setting.
- gfRepeater_getChoiceValue now gets the input values instead of labels. (Issue #22)
- Form editor will no longer let you screw up repeater fields and will notify you if you are trying to do something you shouldn't. (ie. Nesting repeaters, adding unsupported fields, etc.)
- Repeater button in the form editor has been moved to the "Advanced Fields" section.
- Repeater End button has been removed. Repeater end fields are now automatically added and deleted with the repeater start fields.
- Repeated fields with multiple inputs are now stored with their "subId" as key instead of just an increasing numeric key.
- Added support for conditional logic on the repeater start field. Repeater children and repeater end fields are also effected by their repeater start field.
- Added support for fields with "max length" set.
- Added support for fields with "enhanced user interface" enabled.
- Added gform_editor_repeater_field_settings and gform_editor_repeater_end_field_settings filters.
- Added support for animations! (Docs coming soon!)
v1.0.10 (9/06/2017)
- Added support for gravity forms 'Save for later' functionality.
- Added support for multi page gravity form
- Fixed a few other bugs

v1.0.9 (1/25/2016)
- Fixed bug where in some cases a PHP error would occur when attempting to automatically disable ajax on a form. (Issue #18)
- Fixed bug where sometimes a javascript error would occur on date fields with a calendar icon. (Issue #15)
- Fixed bug where in some cases a PHP error would occur when attempting to automatically disable ajax on a form.
- Fixed bug where sometimes a javascript error would occur on date fields with a calendar icon.
- Fixed bug where removing a specific repeatId would cause some weird things to happen.
- Fixed bug where repeaters in a multipage form that are not on the first page would appear to have failed validation even if the form hasn't been submitted.
- Fixed bug where repeaters in a muttipage form that are not on the first page would forget their saved data and ignore their start setting.
Expand All @@ -36,7 +21,7 @@ v1.0.9 (1/25/2016)
- When exporting entries, repeater child data is now exported in a comma-separated list.

v1.0.8 (12/30/2015)
- Fixed bug where sometimes for some reason an input name would be sent as an array and cause a PHP error to display. (Issue #6)
- Fixed bug where sometimes for some reason an input name would be sent as an array and cause a PHP error to display.
- Fixed bug where sometimes validation message would be displayed multiple times for same field.
- Fixed bug where filters would not be loaded if Repeater was the first field on the form.
- Fixed bug where sometimes captured repeater input data would be applied to other forms in cases where there are multiple forms on one page.
Expand Down
20 changes: 7 additions & 13 deletions class-gf-field-repeater-end.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@ public function get_form_editor_field_title() {
}

public function get_form_editor_field_settings() {
return apply_filters('gform_editor_repeater_end_field_settings',
array(
'css_class_setting'
)
return array(
'css_class_setting'
);
}

public function add_button($field_groups) {
return $field_groups;
}

public static function gform_standard_settings($position, $form_id) {
if ($position == 1600) {
echo "<li class=\"repeater_end_settings field_setting\">
Expand Down Expand Up @@ -76,9 +70,9 @@ public static function gform_editor() {
}

public static function gform_tooltips($tooltips) {
$tooltips['form_field_repeater_end_add'] = __( "The HTML to replace the default add button. This HTML will be placed inside of a span tag with the class 'gf_repeater_add'.", 'gravityformsrepeater' );
$tooltips['form_field_repeater_end_remove'] = __( "The HTML to replace the default remove button. This HTML will be placed inside of a span tag with the class 'gf_repeater_remove'.", 'gravityformsrepeater' );
$tooltips['form_field_repeater_end_hideButtons'] = __( "If enabled, no add and remove buttons will be displayed. This is useful if you plan on using custom javascript to trigger the repeater.", 'gravityformsrepeater' );
$tooltips['form_field_repeater_end_add'] = "The HTML to replace the default add button. This HTML will be placed inside of a span tag with the class 'gf_repeater_add'.";
$tooltips['form_field_repeater_end_remove'] = "The HTML to replace the default remove button. This HTML will be placed inside of a span tag with the class 'gf_repeater_remove'.";
$tooltips['form_field_repeater_end_hideButtons'] = "If enabled, no add and remove buttons will be displayed. This is useful if you plan on using custom javascript to trigger the repeater.";
return $tooltips;
}

Expand All @@ -104,13 +98,13 @@ public function get_field_content($value, $force_frontend_label, $form) {
$field_content = "<div class=\"ginput_container ginput_container_repeater-end\">\n";

if (!$hideButtons) {
$field_content .= "<span class=\"gf_repeater_remove\" {$tabindex}>{$remove_html}</span>";
$field_content .= "<span class=\"gf_repeater_add\" {$tabindex}>{$add_html}</span>";
$field_content .= "<span class=\"gf_repeater_remove\" {$tabindex}>{$remove_html}</span>";
}

$field_content .= "</div>";
}
return $field_content;
}
}
GF_Fields::register(new GF_Field_Repeater_End());
GF_Fields::register(new GF_Field_Repeater_End());
Loading