Skip to content

Commit

Permalink
forms update
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Sep 1, 2023
1 parent ab12168 commit 9f05493
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion eightshift-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Eightshift Forms is a complete form builder plugin that utilizes modern Block editor features with multiple third-party integrations, bringing your project to a new level.
* Author: WordPress team @Infinum
* Author URI: https://eightshift.com/
* Version: 4.0.72
* Version: 4.0.73
* Text Domain: eightshift-forms
*
* @package EightshiftForms
Expand Down
7 changes: 6 additions & 1 deletion src/Blocks/components/country/country-style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@
background-repeat: no-repeat;
width: $width;
height: $height;
display: inline-block;
vertical-align: middle;
margin-right: 10px;
display: inline-block;
}

$i: 0;
Expand All @@ -286,5 +286,10 @@

$i: $i + 1;
}

// If placeholder is used.
&:not([data-country-code])::before {
display: none !important; // stylelint-disable-line declaration-no-important
}
}
}
6 changes: 6 additions & 0 deletions src/Blocks/components/form/assets/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ export class Form {

const countryCookie = cookies.getCookie('esForms-country')?.toLocaleLowerCase();
if (countryCookie) {

choices.setChoiceByValue(countryCookie);
}

Expand Down Expand Up @@ -1354,6 +1355,11 @@ export class Form {
const type = field.getAttribute(this.state.getStateAttribute('fieldType'));
const name = field.getAttribute(this.state.getStateAttribute('fieldName'));

// Skip select search field.
if (event?.target?.type === 'search' && event?.target?.name === 'search_terms') {
return;
}

setStateValues(event.target, this.state.getFormIdByElement(event.target));

if (this.state.getStateElementHasChanged(name, formId)) {
Expand Down
5 changes: 5 additions & 0 deletions src/Blocks/components/form/assets/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ export class Utils {
const items = this.state.getStateElementItems(name, formId);
const initial = this.state.getStateElementInitial(name, formId);

// Skip select search field.
if (name === 'search_terms') {
continue;
}

switch (type) {
case 'checkbox':
this.state.setStateElementValue(name, {...initial}, formId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const SelectOptionOptions = (attributes) => {
const selectOptionValue = checkAttr('selectOptionValue', attributes, manifest);
const selectOptionIsSelected = checkAttr('selectOptionIsSelected', attributes, manifest);
const selectOptionIsDisabled = checkAttr('selectOptionIsDisabled', attributes, manifest);
const selectOptionIsHidden = checkAttr('selectOptionIsHidden', attributes, manifest);
const selectOptionDisabledOptions = checkAttr('selectOptionDisabledOptions', attributes, manifest);

return (
Expand Down Expand Up @@ -60,6 +61,13 @@ export const SelectOptionOptions = (attributes) => {
onChange={(value) => setAttributes({ [getAttrKey('selectOptionIsDisabled', attributes, manifest)]: value })}
disabled={isOptionDisabled(getAttrKey('selectOptionIsDisabled', attributes, manifest), selectOptionDisabledOptions)}
/>
<IconToggle
icon={icons.hide}
label={__('Hidden', 'eightshift-forms')}
checked={selectOptionIsHidden}
onChange={(value) => setAttributes({ [getAttrKey('selectOptionIsHidden', attributes, manifest)]: value })}
disabled={isOptionDisabled(getAttrKey('selectOptionIsHidden', attributes, manifest), selectOptionDisabledOptions)}
/>
</PanelBody>

<ConditionalTagsOptions
Expand Down
4 changes: 4 additions & 0 deletions src/Blocks/components/select-option/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
"type": "boolean",
"default": false
},
"selectOptionIsHidden": {
"type": "boolean",
"default": false
},
"selectOptionDisabledOptions": {
"type": "array"
},
Expand Down
5 changes: 5 additions & 0 deletions src/Blocks/components/select-option/select-option.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
$selectOptionLabel = Components::checkAttr('selectOptionLabel', $attributes, $manifest);
$selectOptionIsSelected = Components::checkAttr('selectOptionIsSelected', $attributes, $manifest);
$selectOptionIsDisabled = Components::checkAttr('selectOptionIsDisabled', $attributes, $manifest);
$selectOptionIsHidden = Components::checkAttr('selectOptionIsHidden', $attributes, $manifest);
$selectOptionAttrs = Components::checkAttr('selectOptionAttrs', $attributes, $manifest);

if ($selectOptionIsHidden) {
return;
}

$conditionalTags = Components::render(
'conditional-tags',
Components::props('conditionalTags', $attributes)
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function validateParams(array $data): array
switch ($dataKey) {
// Check validation for required params.
case 'isRequired':
if (empty($inputValue)) {
if (\preg_match('/^\s*$/u', $inputValue) === 1) {
$output[$paramKey] = $this->getValidationLabel('validationRequired', $formId);
}
break;
Expand Down

0 comments on commit 9f05493

Please sign in to comment.