class-evf-field-address.php
1 year ago
class-evf-field-ai.php
1 year ago
class-evf-field-captcha.php
1 month ago
class-evf-field-checkbox.php
3 months ago
class-evf-field-color.php
1 month ago
class-evf-field-country.php
3 months ago
class-evf-field-credit-card.php
1 month ago
class-evf-field-date-time.php
1 month ago
class-evf-field-divider.php
2 years ago
class-evf-field-email.php
1 year ago
class-evf-field-file-upload.php
1 year ago
class-evf-field-first-name.php
1 year ago
class-evf-field-hcaptcha.php
4 months ago
class-evf-field-hidden.php
1 year ago
class-evf-field-html.php
9 months ago
class-evf-field-image-upload.php
1 year ago
class-evf-field-last-name.php
1 year ago
class-evf-field-likert.php
1 year ago
class-evf-field-lookup.php
1 month ago
class-evf-field-number.php
1 year ago
class-evf-field-password.php
1 month ago
class-evf-field-payment-authorize-net.php
1 month ago
class-evf-field-payment-checkbox.php
1 month ago
class-evf-field-payment-coupon.php
1 month ago
class-evf-field-payment-gateway-selector.php
1 month ago
class-evf-field-payment-quantity.php
1 month ago
class-evf-field-payment-radio.php
1 month ago
class-evf-field-payment-single.php
1 month ago
class-evf-field-payment-square.php
1 year ago
class-evf-field-payment-subscription-plan.php
1 month ago
class-evf-field-payment-subtotal.php
1 month ago
class-evf-field-payment-total.php
1 month ago
class-evf-field-phone.php
1 year ago
class-evf-field-privacy-policy.php
3 months ago
class-evf-field-private-note.php
1 year ago
class-evf-field-progress.php
1 month ago
class-evf-field-radio.php
3 months ago
class-evf-field-range-slider.php
1 month ago
class-evf-field-rating.php
3 months ago
class-evf-field-recaptcha.php
4 months ago
class-evf-field-repeater.php
1 month ago
class-evf-field-reset.php
1 month ago
class-evf-field-scale-rating.php
1 year ago
class-evf-field-select.php
1 year ago
class-evf-field-signature.php
1 month ago
class-evf-field-text.php
1 year ago
class-evf-field-textarea.php
1 year ago
class-evf-field-title.php
2 years ago
class-evf-field-turnstile.php
4 months ago
class-evf-field-url.php
1 year ago
class-evf-field-wysiwyg.php
3 months ago
class-evf-field-yes-no.php
1 year ago
payment-amount-helpers.php
1 month ago
class-evf-field-repeater.php
213 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Repeater field |
| 4 | * |
| 5 | * @package EverestForms\Fields |
| 6 | * @since 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | /** |
| 12 | * EVF_Field_Repeater Class. |
| 13 | */ |
| 14 | class EVF_Field_Repeater extends EVF_Form_Fields { |
| 15 | |
| 16 | /** |
| 17 | * Constructor. |
| 18 | */ |
| 19 | public function __construct() { |
| 20 | $this->name = esc_html__( 'Repeater Fields', 'everest-forms' ); |
| 21 | $this->type = 'repeater-fields'; |
| 22 | $this->icon = 'evf-icon evf-icon-repeater'; |
| 23 | $this->order = 190; |
| 24 | $this->group = 'advanced'; |
| 25 | $this->is_pro = true; |
| 26 | $this->plan = 'personal agency themegrill-agency'; |
| 27 | $this->addon = 'everest-forms-repeater-fields'; |
| 28 | $this->links = array( |
| 29 | 'image_id' => '', |
| 30 | 'vedio_id' => 'IBfI1wBxUVY', |
| 31 | ); |
| 32 | $this->settings = array( |
| 33 | 'basic-options' => array( |
| 34 | 'field_options' => array( |
| 35 | 'label', |
| 36 | 'meta', |
| 37 | 'description', |
| 38 | ), |
| 39 | ), |
| 40 | 'advanced-options' => array( |
| 41 | 'field_options' => array( |
| 42 | 'repeater_field_hide', |
| 43 | 'repeater_repeat_limit', |
| 44 | 'repeater_button_add_new_label', |
| 45 | 'repeater_button_remove_label', |
| 46 | 'label_hide', |
| 47 | 'css', |
| 48 | ), |
| 49 | ), |
| 50 | ); |
| 51 | |
| 52 | parent::__construct(); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Field preview inside the builder (matches the Pro repeater builder preview, |
| 57 | * which renders just the label + description; the repeatable rows are added by |
| 58 | * JS at runtime in the Pro addon). |
| 59 | * |
| 60 | * @param array $field Field data and settings. |
| 61 | */ |
| 62 | public function field_preview( $field ) { |
| 63 | // Label. |
| 64 | $this->field_preview_option( 'label', $field ); |
| 65 | |
| 66 | // Description. |
| 67 | $this->field_preview_option( 'description', $field ); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Option to show Repeater Field or not. |
| 72 | * |
| 73 | * @param array $field Field Data. |
| 74 | * @return void |
| 75 | */ |
| 76 | public function repeater_field_hide( $field ) { |
| 77 | $input_field = $this->field_element( |
| 78 | 'checkbox', |
| 79 | $field, |
| 80 | array( |
| 81 | 'slug' => 'repeater_field_hide', |
| 82 | 'value' => isset( $field['repeater_field_hide'] ) ? $field['repeater_field_hide'] : 0, |
| 83 | 'desc' => esc_html__( 'Hide Repeater Field?', 'everest-forms' ), |
| 84 | 'tooltip' => esc_html__( 'Hide the repeater field from the frontend form view.', 'everest-forms' ), |
| 85 | ), |
| 86 | false |
| 87 | ); |
| 88 | $this->field_element( |
| 89 | 'row', |
| 90 | $field, |
| 91 | array( |
| 92 | 'slug' => 'repeater_field_hide', |
| 93 | 'content' => $input_field, |
| 94 | ) |
| 95 | ); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Repeat Limit for Repeater Fields. |
| 100 | * |
| 101 | * @param array $field Field Data. |
| 102 | * @return void |
| 103 | */ |
| 104 | public function repeater_repeat_limit( $field ) { |
| 105 | $label = $this->field_element( |
| 106 | 'label', |
| 107 | $field, |
| 108 | array( |
| 109 | 'slug' => 'repeater_repeat_limit', |
| 110 | 'value' => esc_html__( 'Repeat Limit', 'everest-forms' ), |
| 111 | 'tooltip' => esc_html__( 'Max number of times a user can add repeater fields.', 'everest-forms' ), |
| 112 | ), |
| 113 | false |
| 114 | ); |
| 115 | $input_field = $this->field_element( |
| 116 | 'text', |
| 117 | $field, |
| 118 | array( |
| 119 | 'type' => 'number', |
| 120 | 'slug' => 'repeater_repeat_limit', |
| 121 | 'class' => 'evf-input-number-repeater-repeat-limit', |
| 122 | 'value' => isset( $field['repeater_repeat_limit'] ) ? $field['repeater_repeat_limit'] : '', |
| 123 | 'min' => 0, |
| 124 | ), |
| 125 | false |
| 126 | ); |
| 127 | $this->field_element( |
| 128 | 'row', |
| 129 | $field, |
| 130 | array( |
| 131 | 'slug' => 'repeater_repeat_limit', |
| 132 | 'content' => $label . $input_field, |
| 133 | ) |
| 134 | ); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Customize label name for Add New Button. |
| 139 | * |
| 140 | * @param array $field Field Data. |
| 141 | * @return void |
| 142 | */ |
| 143 | public function repeater_button_add_new_label( $field ) { |
| 144 | $label = $this->field_element( |
| 145 | 'label', |
| 146 | $field, |
| 147 | array( |
| 148 | 'slug' => 'repeater_button_add_new_label', |
| 149 | 'value' => esc_html__( 'Add New Label', 'everest-forms' ), |
| 150 | 'tooltip' => esc_html__( 'Change label of Add button for repeater fields.', 'everest-forms' ), |
| 151 | ), |
| 152 | false |
| 153 | ); |
| 154 | $input_field = $this->field_element( |
| 155 | 'text', |
| 156 | $field, |
| 157 | array( |
| 158 | 'type' => 'text', |
| 159 | 'slug' => 'repeater_button_add_new_label', |
| 160 | 'class' => 'evf-input-number-repeater-button-add-new-label', |
| 161 | 'value' => isset( $field['repeater_button_add_new_label'] ) ? $field['repeater_button_add_new_label'] : 'Add', |
| 162 | ), |
| 163 | false |
| 164 | ); |
| 165 | $this->field_element( |
| 166 | 'row', |
| 167 | $field, |
| 168 | array( |
| 169 | 'slug' => 'repeater_button_add_new_label', |
| 170 | 'content' => $label . $input_field, |
| 171 | ) |
| 172 | ); |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Customize label name for Remove Button. |
| 177 | * |
| 178 | * @param array $field Field Data. |
| 179 | * @return void |
| 180 | */ |
| 181 | public function repeater_button_remove_label( $field ) { |
| 182 | $label = $this->field_element( |
| 183 | 'label', |
| 184 | $field, |
| 185 | array( |
| 186 | 'slug' => 'repeater_button_remove_label', |
| 187 | 'value' => esc_html__( 'Remove Label', 'everest-forms' ), |
| 188 | 'tooltip' => esc_html__( 'Change label of Remove button for repeater fields.', 'everest-forms' ), |
| 189 | ), |
| 190 | false |
| 191 | ); |
| 192 | $input_field = $this->field_element( |
| 193 | 'text', |
| 194 | $field, |
| 195 | array( |
| 196 | 'type' => 'text', |
| 197 | 'slug' => 'repeater_button_remove_label', |
| 198 | 'class' => 'evf-input-number-repeater-button-remove-new-label', |
| 199 | 'value' => isset( $field['repeater_button_remove_label'] ) ? $field['repeater_button_remove_label'] : 'Remove', |
| 200 | ), |
| 201 | false |
| 202 | ); |
| 203 | $this->field_element( |
| 204 | 'row', |
| 205 | $field, |
| 206 | array( |
| 207 | 'slug' => 'repeater_button_remove_label', |
| 208 | 'content' => $label . $input_field, |
| 209 | ) |
| 210 | ); |
| 211 | } |
| 212 | } |
| 213 |