Add validation
[MAILPOET-2453]
This commit is contained in:
committed by
Rostislav Wolný
parent
eeaec19a6b
commit
f5d882b5e5
@@ -22,6 +22,10 @@ export function getSettings(customField) {
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
validate: {
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
customFieldId: {
|
customFieldId: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: customField.id,
|
default: customField.id,
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
Panel,
|
Panel,
|
||||||
PanelBody,
|
PanelBody, SelectControl,
|
||||||
TextControl,
|
TextControl,
|
||||||
ToggleControl,
|
ToggleControl,
|
||||||
} from '@wordpress/components';
|
} from '@wordpress/components';
|
||||||
@@ -30,6 +30,28 @@ const FirstNameEdit = ({ attributes, setAttributes }) => {
|
|||||||
checked={attributes.mandatory}
|
checked={attributes.mandatory}
|
||||||
onChange={(mandatory) => (setAttributes({ mandatory }))}
|
onChange={(mandatory) => (setAttributes({ mandatory }))}
|
||||||
/>
|
/>
|
||||||
|
<SelectControl
|
||||||
|
label={`${MailPoet.I18n.t('customFieldValidateFor')}:`}
|
||||||
|
options={[
|
||||||
|
{
|
||||||
|
label: MailPoet.I18n.t('customFieldValidateNothing'),
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: MailPoet.I18n.t('customFieldValidateNumbersOnly'),
|
||||||
|
value: 'alphanum',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: MailPoet.I18n.t('customFieldValidateAlphanumerical'),
|
||||||
|
value: 'number',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: MailPoet.I18n.t('customFieldValidatePhoneNumber'),
|
||||||
|
value: 'phone',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
onChange={(validate) => (setAttributes({ validate }))}
|
||||||
|
/>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|
||||||
|
@@ -43,6 +43,11 @@
|
|||||||
'settingsPleaseSelectList': __('Please select a list'),
|
'settingsPleaseSelectList': __('Please select a list'),
|
||||||
'fieldsBlocksCategory': __('Fields'),
|
'fieldsBlocksCategory': __('Fields'),
|
||||||
'customFieldsBlocksCategory': __('Custom Fields'),
|
'customFieldsBlocksCategory': __('Custom Fields'),
|
||||||
|
'customFieldValidateFor': __('Validate for'),
|
||||||
|
'customFieldValidateNothing': __('Nothing'),
|
||||||
|
'customFieldValidateNumbersOnly': __('Numbers only'),
|
||||||
|
'customFieldValidateAlphanumerical': __('Alphanumerical'),
|
||||||
|
'customFieldValidatePhoneNumber': __('Phone number, (+,-,#,(,) and spaces allowed)'),
|
||||||
'blockMandatory': __('Mandatory field'),
|
'blockMandatory': __('Mandatory field'),
|
||||||
'blockFirstName': __('First name'),
|
'blockFirstName': __('First name'),
|
||||||
'blockFirstNameDescription': __('Input field used to catch subscribers’ first names.'),
|
'blockFirstNameDescription': __('Input field used to catch subscribers’ first names.'),
|
||||||
|
Reference in New Issue
Block a user