| @@ -139,11 +139,10 @@ | ||
| 139 | 139 | $field['recaptcha_theme'] = isset( $field['recaptcha_theme'] ) ? $field['recaptcha_theme'] : 'light'; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // Check if meta_key has changed when saving form compared current entries |
| 143 | - if ( isset( $field['name'] ) ) { | |
| 144 | - $field['original_name'] = $field['name']; | |
| 145 | - } | |
| 143 | + $field['original_name'] = $field['name']; | |
| 144 | + | |
| 146 | 145 | $form_fields[] = apply_filters( 'weforms-get-form-field', $field, $this->id ); |
| 147 | 146 | } |
| 148 | 147 | |
| 149 | 148 | $this->form_fields = apply_filters( 'weforms-get-form-fields', $form_fields, $this->id ); |
| @@ -373,11 +372,11 @@ | ||
| 373 | 372 | |
| 374 | 373 | /** |
| 375 | 374 | * When a user is editing their form they may change a fields name. |
| 376 | 375 | * This method will loop through existing entries to match the new field names. |
| 377 | - * | |
| 376 | + * | |
| 378 | 377 | * @since 1.6.9 |
| 379 | - * | |
| 378 | + * | |
| 380 | 379 | * @param int $form_id |
| 381 | 380 | * @param array $form_fields |
| 382 | 381 | */ |
| 383 | 382 | public function maybe_update_entries( $form_fields ) { |
| @@ -386,18 +385,18 @@ | ||
| 386 | 385 | foreach ( $changed_fields as $old => $new) { |
| 387 | 386 | $updated_fields = $this->rename_field( $old, $new ); |
| 388 | 387 | } |
| 389 | 388 | } |
| 390 | - | |
| 389 | + | |
| 391 | 390 | /** |
| 392 | 391 | * When a user is editing their form they may change a fields name. |
| 393 | 392 | * This method will loop through all fields that have changed. |
| 394 | - * | |
| 393 | + * | |
| 395 | 394 | * @since 1.6.9 |
| 396 | - * | |
| 395 | + * | |
| 397 | 396 | * @param int $form_id |
| 398 | 397 | * @param array $form_fields |
| 399 | - * | |
| 398 | + * | |
| 400 | 399 | * @return array |
| 401 | 400 | */ |
| 402 | 401 | public function get_changed_fields( $form_fields ) { |
| 403 | 402 | $changed_fields = array(); |
| @@ -402,8 +401,9 @@ | ||
| 402 | 401 | public function get_changed_fields( $form_fields ) { |
| 403 | 402 | $changed_fields = array(); |
| 404 | 403 | foreach ( $form_fields as $field ) { |
| 405 | 404 | $org_field = $field['original_name']; |
| 405 | + error_log("Org Field" . " = " . print_r($org_field,1)); | |
| 406 | 406 | // All form fields should have an original name. |
| 407 | 407 | if ( empty( $field['original_name'] ) ) { |
| 408 | 408 | continue; |
| 409 | 409 | } |
| @@ -419,14 +419,14 @@ | ||
| 419 | 419 | |
| 420 | 420 | /** |
| 421 | 421 | * When a user changes the field names of a form, the existing entries will need updated. |
| 422 | 422 | * This method will loop through the existing entries and update them will the new names. |
| 423 | - * | |
| 423 | + * | |
| 424 | 424 | * @since 1.6.9 |
| 425 | - * | |
| 425 | + * | |
| 426 | 426 | * @param int $form_id |
| 427 | 427 | * @param array $form_fields |
| 428 | - * | |
| 428 | + * | |
| 429 | 429 | * @return array |
| 430 | 430 | */ |
| 431 | 431 | public function rename_field ( $old, $new ) { |
| 432 | 432 | global $wpdb; |
| @@ -432,9 +432,9 @@ | ||
| 432 | 432 | global $wpdb; |
| 433 | 433 | |
| 434 | 434 | $entries = weforms_get_form_entries( $this->id ); |
| 435 | 435 | |
| 436 | - foreach ( $entries as $entry ) { | |
| 436 | + foreach ( $entries as $entry ) { | |
| 437 | 437 | $entry_id = $entry->id; |
| 438 | 438 | $values = weforms_get_entry_meta( $entry_id ); |
| 439 | 439 | $update_keys = $wpdb->update( $wpdb->weforms_entrymeta, array( 'meta_key' => $new ), array( 'meta_key' => $old, 'weforms_entry_id' => $entry_id ) ); |
| 440 | 440 | } |