| @@ -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 ); |
| @@ -384,8 +385,33 @@ | ||
| 384 | 385 | } |
| 385 | 386 | self::clear_form_cache(); |
| 386 | 387 | |
| 387 | 388 | return $values; |
| 389 | + } | |
| 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 | + } | |
| 388 | 414 | } |
| 389 | 415 | |
| 390 | 416 | /** |
| 391 | 417 | * @param string $opt |