diff --git a/changelog.txt b/changelog.txt index fe94a4a9cf..f1c83d6bfe 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ = 6.16 = * New: The sanitizing for layout classes has been updated to allow `[` and `]` characters, enabling the use of basic shortcodes. * Fix: JavaScript validation would get skipped when a form included an invisible reCAPTCHA field. +* Fix: Submit buttons would appear out of place after saving a form. * Fix: Nothing would copy when trying to click the icon to copy a style class name. * Fix: A white element would appear at the bottom of the plugins page. * Fix: A Cannot read properties of undefined at removeFieldError error has been fixed. diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index bdf4d0874e..f271a01a04 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -170,7 +170,7 @@ private static function create_submit_button_field( $form ) { array( 'type' => FrmSubmitHelper::FIELD_TYPE, 'name' => __( 'Submit', 'formidable' ), - 'field_order' => 9999, + 'field_order' => FrmSubmitHelper::DEFAULT_ORDER, 'form_id' => $form->id, 'field_options' => FrmFieldsHelper::get_default_field_options( FrmSubmitHelper::FIELD_TYPE ), 'description' => '', diff --git a/classes/helpers/FrmSubmitHelper.php b/classes/helpers/FrmSubmitHelper.php index 067c6d94ea..87c22fe181 100644 --- a/classes/helpers/FrmSubmitHelper.php +++ b/classes/helpers/FrmSubmitHelper.php @@ -22,6 +22,13 @@ class FrmSubmitHelper { */ const FIELD_TYPE = 'submit'; + /** + * Default order for submit field. + * + * @var int + */ + const DEFAULT_ORDER = 9999; + /** * Gets submit field object. * diff --git a/classes/models/FrmForm.php b/classes/models/FrmForm.php index 1c19afa664..b119ed3f1b 100644 --- a/classes/models/FrmForm.php +++ b/classes/models/FrmForm.php @@ -514,11 +514,14 @@ private static function prepare_field_update_values( $field, $values, &$new_fiel 'name' => '', ); foreach ( $field_cols as $col => $default ) { - $default = $default === '' ? $field->{$col} : $default; - + $default = $default === '' ? $field->{$col} : $default; $new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default; } + if ( $field->type === 'submit' && isset( $new_field['field_order'] ) && (int) $new_field['field_order'] === FrmSubmitHelper::DEFAULT_ORDER ) { + $new_field['field_order'] = $field->field_order; + } + // Don't save the template option. if ( is_array( $new_field['options'] ) && isset( $new_field['options']['000'] ) ) { unset( $new_field['options']['000'] ); diff --git a/readme.txt b/readme.txt index 27f55c3663..025380af68 100644 --- a/readme.txt +++ b/readme.txt @@ -374,6 +374,7 @@ See all [Formidable Zapier Integrations](https://zapier.com/apps/formidable/inte = 6.16 = * New: The sanitizing for layout classes has been updated to allow `[` and `]` characters, enabling the use of basic shortcodes. * Fix: JavaScript validation would get skipped when a form included an invisible reCAPTCHA field. +* Fix: Submit buttons would appear out of place after saving a form. * Fix: Nothing would copy when trying to click the icon to copy a style class name. * Fix: A white element would appear at the bottom of the plugins page. * Fix: A Cannot read properties of undefined at removeFieldError error has been fixed.