| @@ -79,8 +79,12 @@ | ||
| 79 | 79 | 'credit_card' => array( |
| 80 | 80 | 'name' => __( 'Payment', 'formidable' ), |
| 81 | 81 | 'icon' => 'frmfont frm_credit_card2_icon', |
| 82 | 82 | ), |
| 83 | + 'address' => array( | |
| 84 | + 'name' => __( 'Address', 'formidable' ), | |
| 85 | + 'icon' => 'frmfont frm_location2_icon', | |
| 86 | + ), | |
| 83 | 87 | FrmSubmitHelper::FIELD_TYPE => array( |
| 84 | 88 | 'name' => __( 'Submit', 'formidable' ), |
| 85 | 89 | 'hide' => true, |
| 86 | 90 | ), |
| @@ -438,8 +442,9 @@ | ||
| 438 | 442 | unset( $pro_fields['credit_card'] ); |
| 439 | 443 | unset( $pro_fields['product'] ); |
| 440 | 444 | unset( $pro_fields['quantity'] ); |
| 441 | 445 | unset( $pro_fields['total'] ); |
| 446 | + unset( $pro_fields['address'] ); | |
| 442 | 447 | } |
| 443 | 448 | |
| 444 | 449 | /** |
| 445 | 450 | * @since 4.0 |
| @@ -472,13 +477,19 @@ | ||
| 472 | 477 | $new_values[ $col ] = $values[ $col ]; |
| 473 | 478 | } |
| 474 | 479 | } |
| 475 | 480 | |
| 476 | - $new_values['options'] = self::maybe_filter_options( $values['options'] ); | |
| 481 | + // Both option columns are stored serialized, but they do not accept the same shapes. | |
| 482 | + // Choice fields pass options already serialized, as does FrmFieldsHelper::fill_field | |
| 483 | + // when a field is duplicated, and fields with no choices pass an empty string, so a | |
| 484 | + // missing key is the only thing worth defaulting. An is_array check here would throw | |
| 485 | + // every one of those defaults away. field_options is always an array, so anything | |
| 486 | + // else is invalid input, and replacing it stops consumers getting null. | |
| 487 | + $new_values['options'] = self::maybe_filter_options( $values['options'] ?? array() ); | |
| 477 | 488 | $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null; |
| 478 | 489 | $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0; |
| 479 | 490 | $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null; |
| 480 | - $new_values['field_options'] = $values['field_options']; | |
| 491 | + $new_values['field_options'] = isset( $values['field_options'] ) && is_array( $values['field_options'] ) ? $values['field_options'] : array(); | |
| 481 | 492 | $new_values['created_at'] = current_time( 'mysql', 1 ); |
| 482 | 493 | |
| 483 | 494 | if ( isset( $values['id'] ) ) { |
| 484 | 495 | $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key']; |
| @@ -521,9 +532,9 @@ | ||
| 521 | 532 | * See FrmAppHelper::allow_unfiltered_html. |
| 522 | 533 | * |
| 523 | 534 | * @since 5.0.08 |
| 524 | 535 | * |
| 525 | - * @param array $options | |
| 536 | + * @param array|string $options Already serialized for choice fields, and an empty string for fields with no choices. | |
| 526 | 537 | * |
| 527 | 538 | * @return array |
| 528 | 539 | */ |
| 529 | 540 | private static function maybe_filter_options( $options ) { |