| @@ -376,8 +376,9 @@ | ||
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | self::prepare_field_update_values( $field, $values, $new_field ); |
| 380 | + self::maybe_update_max_option( $field, $values, $new_field ); | |
| 380 | 381 | |
| 381 | 382 | FrmField::update( $field_id, $new_field ); |
| 382 | 383 | |
| 383 | 384 | FrmField::delete_form_transient( $field->form_id ); |
| @@ -387,8 +388,33 @@ | ||
| 387 | 388 | return $values; |
| 388 | 389 | } |
| 389 | 390 | |
| 390 | 391 | /** |
| 392 | + * Resets the 'max' option of a field when changing paragraph field type to other field types like text, email etc. | |
| 393 | + * | |
| 394 | + * @since 6.7 | |
| 395 | + * | |
| 396 | + * @param array $field | |
| 397 | + * @param array $values | |
| 398 | + * @param array $new_field | |
| 399 | + * @return void | |
| 400 | + */ | |
| 401 | + private static function maybe_update_max_option( $field, $values, &$new_field ) { | |
| 402 | + if ( $field->type === 'textarea' && | |
| 403 | + ! empty( $values['field_options'][ 'type_' . $field->id ] ) && | |
| 404 | + in_array( $values['field_options'][ 'type_' . $field->id ], array( 'text', 'email', 'url', 'password', 'phone' ), true ) ) { | |
| 405 | + | |
| 406 | + $new_field['field_options']['max'] = ''; | |
| 407 | + | |
| 408 | + /** | |
| 409 | + * Update posted field setting so that new 'max' option is displayed after form is saved and page reloads. | |
| 410 | + * FrmFieldsHelper::fill_default_field_opts populates field options by calling self::get_posted_field_setting. | |
| 411 | + */ | |
| 412 | + $_POST['field_options'][ 'max_' . $field->id ] = ''; | |
| 413 | + } | |
| 414 | + } | |
| 415 | + | |
| 416 | + /** | |
| 391 | 417 | * @param string $opt |
| 392 | 418 | * @param mixed $value |
| 393 | 419 | * @return void |
| 394 | 420 | */ |
| @@ -687,9 +713,11 @@ | ||
| 687 | 713 | } |
| 688 | 714 | |
| 689 | 715 | $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
| 690 | 716 | $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
| 691 | - $r = stripslashes( $r ); | |
| 717 | + | |
| 718 | + // An empty form name can result in a null value. | |
| 719 | + $r = is_null( $r ) ? '' : stripslashes( $r ); | |
| 692 | 720 | |
| 693 | 721 | return $r; |
| 694 | 722 | } |
| 695 | 723 | |