- added validation for some settings releated to form fields;
This commit is contained in:
@@ -21,7 +21,7 @@ const BuilderElementSettings = ({ closeSettings }) => {
|
||||
const [activeElementData, setActiveElementData] = useState({});
|
||||
const [settings, setSettings] = useState([]);
|
||||
const [validators, setValidators] = useState({});
|
||||
const textBasedValidatorFields = ['min', 'max', 'minLength', 'maxLength', 'pattern'];
|
||||
const numberBasedValidatorFields = ['min', 'max', 'minLength', 'maxLength'];
|
||||
const customValidationOptions = [
|
||||
{ value: 'isPIVA', label: 'isPIVA' },
|
||||
{ value: 'isCodiceFiscale', label: 'isCodiceFiscale' },
|
||||
@@ -132,7 +132,7 @@ const BuilderElementSettings = ({ closeSettings }) => {
|
||||
onChange={(e) => toggleRequired(e.value, k)}/>
|
||||
</div>
|
||||
: null}
|
||||
{textBasedValidatorFields.includes(k) || 'custom' === k
|
||||
{numberBasedValidatorFields.includes(k) || 'pattern' === k || 'custom' === k
|
||||
? <div className="formElementSettings__field">
|
||||
<label htmlFor={`enable_${k}`}>{sprintf(__('Set %s', 'gepafin'), k)}</label>
|
||||
<InputSwitch
|
||||
@@ -153,13 +153,23 @@ const BuilderElementSettings = ({ closeSettings }) => {
|
||||
placeholder={__('Scegli', 'gepafin')}/>
|
||||
</div>
|
||||
: null}
|
||||
{textBasedValidatorFields.includes(k) && !isNil(validators[k])
|
||||
{'pattern' === k && !isNil(validators[k])
|
||||
? <div className="formElementSettings__field">
|
||||
<label htmlFor={k}>{k}</label>
|
||||
<InputText id={k} aria-describedby={`${k}-help`}
|
||||
value={validators[k]}
|
||||
onChange={(e) => onChangeValidator(e.target.value, k)}/>
|
||||
</div> : null}
|
||||
{numberBasedValidatorFields.includes(k) && !isNil(validators[k])
|
||||
? <div className="formElementSettings__field">
|
||||
<label htmlFor={k}>{k}</label>
|
||||
<InputText id={k}
|
||||
aria-describedby={`${k}-help`}
|
||||
value={validators[k]}
|
||||
keyfilter="int"
|
||||
placeholder="0"
|
||||
onChange={(e) => onChangeValidator(e.target.value, k)}/>
|
||||
</div> : null}
|
||||
</div>) : null}
|
||||
</TabPanel> : null}
|
||||
</TabView>
|
||||
|
||||
Reference in New Issue
Block a user