Skip to content

Commit

Permalink
fix bug in back-end when defining conditional logic and conditional v…
Browse files Browse the repository at this point in the history
…alidation due to condition not allowed to be the same as current editing field name
  • Loading branch information
RensTillmann committed Feb 4, 2022
1 parent c7faea7 commit 8ada92e
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 14 deletions.
3 changes: 2 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

- [PDF Generator Add-on](https://renstillmann.github.io/super-forms/#/pdf-generator-add-on)

## Feb 03, 2022 - Version 6.1.4
## Feb 04, 2022 - Version 6.1.5

- **Fix:** In the back-end when defining condtional logic for a field the user was not able to define a `Value` comparison that had the same value as the current field name e.g: `DC` field name and having a conditional logic value equals to `DC` which should be allowed. However the `Field name` isn't allowed to point to the current field, so that still needs to be validated
- **Fix:** Redirect message undefined in JS, causing form not redirecting at all
- **Fix:** Toggle button alignment for `Field label` and `Field description`
- **Fix:** Issue with WooCommerce Checkout
Expand Down
59 changes: 56 additions & 3 deletions src/assets/css/backend/create-form.css
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@
float: left;
text-align: center;
border: 2px dashed #000000;
border-radius: 0;
}

.super-header p {
Expand Down Expand Up @@ -2994,14 +2995,17 @@ body:not(.tox-fullscreen) .super-builder .tox-editor-header .tox-menubar .tox-mb
.sfui-setting .sfui-setting .sfui-setting {
padding: 5px 5px 10px 10px !important;
}
.sfui-setting input,
.sfui-setting input[type="text"],
.sfui-setting textarea,
.sfui-setting select {
padding: 5px;
padding: 0 5px !important;
border: 1px solid #cccccc;
color: #444;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}
.sfui-setting select {
padding: 0 25px 0 5px !important;
}
.super-color-picker-container:hover .super-reset-default-value,
.super-color-picker-container:hover .super-reset-global-value {
display: flex;
Expand Down Expand Up @@ -3073,4 +3077,53 @@ body:not(.tox-fullscreen) .super-builder .tox-editor-header .tox-menubar .tox-mb
}
.super-form-settings .super-reset-user-submission-counter {
float: left;
}
}
.super-element-settings .super-multi-items .super-error,
.super-form-settings .super-multi-items .super-error {
border: 1px solid #ff9b9b !important;
background-color: #ffd0d0 !important;
}
.super-element-settings .super-multi-items select[name="conditional_and_method"],
.super-form-settings .super-multi-items select[name="conditional_and_method"] {
border-top: 0;
border-bottom: 0;
}
.super-element-settings input,
.super-element-settings textarea,
.super-element-settings select,
.super-form-settings input,
.super-form-settings textarea,
.super-form-settings select {
border-color: none;
box-shadow: none;
outline: none;
}
.super-element-settings input:focus,
.super-element-settings textarea:focus,
.super-element-settings select:focus,
.super-form-settings input:focus,
.super-form-settings textarea:focus,
.super-form-settings select:focus {
border-color: none;
box-shadow: none;
outline: none;
border: 1px solid #818181 !important;
}
.super-element-settings .super-checkbox,
.super-form-settings .super-checkbox {
width: 100% !important;
}
.super-element-settings .super-checkbox > label,
.super-form-settings .super-checkbox > label {
width: 100% !important;
min-height: 25px;
margin: 0 !important;
display: flex !important;
align-items: center;
}
.super-element-settings .super-checkbox > label input[type="checkbox"],
.super-form-settings .super-checkbox > label input[type="checkbox"] {
margin: 0 5px 0 0;
border-radius: 0;
border-color: #ccc;
}
26 changes: 19 additions & 7 deletions src/assets/js/backend/create-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,13 +769,25 @@
// This is not allowed
$input_fields = $this.children('input[name="conditional_field"], input[name="conditional_value"], input[name="conditional_field_and"], input[name="conditional_value_and"], textarea[name="conditional_new_value"]');
$.each($input_fields, function (key, field) {
// As soon a match was found, display the error and stop this loop
if (field.value.indexOf($field_name) !== -1) {
$error = true;
field.classList.add('super-error');
return false;
} else {
field.classList.remove('super-error');
// Conditional logic `field` may not point to it's own field
if(field.name==='conditional_field' || field.name==='conditional_field_and'){
if (field.value.indexOf($field_name) !== -1) {
$error = true;
field.classList.add('super-error');
return false;
} else {
field.classList.remove('super-error');
}
}
// Conditional logic `value` can not compare against it's own field name...
if(field.name==='conditional_value' || field.name==='conditional_value_and'){
if ( (field.value.indexOf('{'+$field_name+'}') !== -1) || (field.value.indexOf('{'+$field_name+';') !== -1) ) {
$error = true;
field.classList.add('super-error');
return false;
} else {
field.classList.remove('super-error');
}
}
});
// Add the conditions to the object so we can store it later
Expand Down
3 changes: 2 additions & 1 deletion src/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

- [PDF Generator Add-on](https://renstillmann.github.io/super-forms/#/pdf-generator-add-on)

## Feb 03, 2022 - Version 6.1.4
## Feb 04, 2022 - Version 6.1.5

- **Fix:** In the back-end when defining condtional logic for a field the user was not able to define a `Value` comparison that had the same value as the current field name e.g: `DC` field name and having a conditional logic value equals to `DC` which should be allowed. However the `Field name` isn't allowed to point to the current field, so that still needs to be validated
- **Fix:** Redirect message undefined in JS, causing form not redirecting at all
- **Fix:** Toggle button alignment for `Field label` and `Field description`
- **Fix:** Issue with WooCommerce Checkout
Expand Down
4 changes: 2 additions & 2 deletions src/super-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @wordpress-plugin
* Plugin Name: Super Forms - Drag & Drop Form Builder
* Description: The most advanced, flexible and easy to use form builder for WordPress!
* Version: 6.1.4
* Version: 6.1.5
* Plugin URI: http://f4d.nl/super-forms
* Author URI: http://f4d.nl/super-forms
* Author: feeling4design
Expand Down Expand Up @@ -43,7 +43,7 @@ final class SUPER_Forms {
*
* @since 1.0.0
*/
public $version = '6.1.4';
public $version = '6.1.5';
public $slug = 'super-forms';
public $apiUrl = 'https://api.super-forms.com/';
public $apiVersion = 'v1';
Expand Down

0 comments on commit 8ada92e

Please sign in to comment.