Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions classes/controllers/FrmStylesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,12 +765,12 @@ private static function manage_styles() {

$forms = FrmForm::get_published_forms();
foreach ( $forms as $form ) {
$new_style = isset( $_POST['style'] ) && isset( $_POST['style'][ $form->id ] ) ? sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
$previous_style = isset( $_POST['prev_style'] ) && isset( $_POST['prev_style'][ $form->id ] ) ? sanitize_text_field( wp_unslash( $_POST['prev_style'][ $form->id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
if ( $new_style == $previous_style ) {
if ( ! isset( $_POST['style'] ) || ! isset( $_POST['style'][ $form->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
continue;
}

$new_style = sanitize_text_field( wp_unslash( $_POST['style'][ $form->id ] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing

$form->options['custom_style'] = $new_style;
$wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) );
unset( $form );
Expand Down
4 changes: 1 addition & 3 deletions classes/views/styles/_manage-styles-row.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
<label for="<?php echo esc_attr( $dropdown_id ); ?>"><?php echo esc_html( $form_name ); ?></label>
</td>
<td>
<input type="hidden" name="prev_style[<?php echo absint( $form->id ); ?>]" value="<?php echo esc_attr( $active_style_id ); ?>" />

<select id="<?php echo esc_attr( $dropdown_id ); ?>" name="style[<?php echo absint( $form->id ); ?>]">
<select id="<?php echo esc_attr( $dropdown_id ); ?>" data-name="style[<?php echo absint( $form->id ); ?>]">
<?php foreach ( $styles as $style ) { ?>
<option value="<?php echo esc_attr( $style->ID ); ?>" <?php selected( $style->ID, $active_style_id ); ?>>
<?php echo esc_html( $style->post_title . ( empty( $style->menu_order ) ? '' : ' (' . __( 'default', 'formidable' ) . ')' ) ); ?>
Expand Down
15 changes: 15 additions & 0 deletions js/formidable_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10926,6 +10926,21 @@ function frmAdminBuildJS() {

// Set fieldsUpdated to 0 to avoid the unsaved changes pop up.
frmDom.util.documentOn( 'submit', '.frm_settings_form', () => fieldsUpdated = 0 );

const manageStyleSettings = document.getElementById( 'manage_styles_settings' );
if ( manageStyleSettings ) {
manageStyleSettings.addEventListener(
'change',
event => {
const target = event.target;
if ( 'SELECT' !== target.nodeName || ! target.dataset.name || target.getAttribute( 'name' ) ) {
return;
}

target.setAttribute( 'name', target.dataset.name );
}
);
}
},

exportInit: function() {
Expand Down