mirror of
https://github.com/strapi/strapi.git
synced 2025-08-28 18:51:33 +00:00
Handle form errors for email-templates
This commit is contained in:
parent
46ecdd1e17
commit
2b099e3a2f
@ -102,13 +102,15 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
|
|||||||
<Input
|
<Input
|
||||||
autoFocus={key === 0}
|
autoFocus={key === 0}
|
||||||
key={value}
|
key={value}
|
||||||
|
didCheckErrors={this.props.didCheckErrors}
|
||||||
|
errors={get(this.props.formErrors, [findIndex(this.props.formErrors, ['name', value]), 'errors'], [])}
|
||||||
label={`users-permissions.PopUpForm.Email.${value}.label`}
|
label={`users-permissions.PopUpForm.Email.${value}.label`}
|
||||||
name={`${dataToEdit}.${value}`}
|
name={`${dataToEdit}.${value}`}
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
placeholder={`users-permissions.PopUpForm.Email.${value}.placeholder`}
|
placeholder={`users-permissions.PopUpForm.Email.${value}.placeholder`}
|
||||||
type={includes(value, 'email') ? 'email' : 'text'}
|
type={includes(value, 'email') ? 'email' : 'text'}
|
||||||
value={get(values, value)}
|
value={get(values, value)}
|
||||||
validations={{}}
|
validations={value !== 'options.response_email' ? { required: true } : {}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<div className="col-md-6" />
|
<div className="col-md-6" />
|
||||||
@ -116,6 +118,8 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
|
|||||||
<Input
|
<Input
|
||||||
key={value}
|
key={value}
|
||||||
customBootstrapClass="col-md-12"
|
customBootstrapClass="col-md-12"
|
||||||
|
didCheckErrors={this.props.didCheckErrors}
|
||||||
|
errors={get(this.props.formErrors, [findIndex(this.props.formErrors, ['name', value]), 'errors'], [])}
|
||||||
label={`users-permissions.PopUpForm.Email.${value}.label`}
|
label={`users-permissions.PopUpForm.Email.${value}.label`}
|
||||||
name={`${dataToEdit}.${value}`}
|
name={`${dataToEdit}.${value}`}
|
||||||
inputDescription={includes(value, 'object') ? 'users-permissions.PopUpForm.Email.email_templates.inputDescription' : ''}
|
inputDescription={includes(value, 'object') ? 'users-permissions.PopUpForm.Email.email_templates.inputDescription' : ''}
|
||||||
@ -123,7 +127,7 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
|
|||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
placeholder={`users-permissions.PopUpForm.Email.${this.props.dataToEdit}.${value}.placeholder`}
|
placeholder={`users-permissions.PopUpForm.Email.${this.props.dataToEdit}.${value}.placeholder`}
|
||||||
type={includes(value, 'object') ? 'text' : 'textarea'}
|
type={includes(value, 'object') ? 'text' : 'textarea'}
|
||||||
validations={{}}
|
validations={{ required: true }}
|
||||||
value={get(values, value)}
|
value={get(values, value)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { get, isEmpty } from 'lodash';
|
import { get, isEmpty, isObject } from 'lodash';
|
||||||
|
|
||||||
export default function checkFormValidity(settingType, data) {
|
export default function checkFormValidity(settingType, data) {
|
||||||
const formErrors = [];
|
const formErrors = [];
|
||||||
@ -15,6 +15,22 @@ export default function checkFormValidity(settingType, data) {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'email-templates': {
|
||||||
|
Object.keys(data.options).map((value) => {
|
||||||
|
if (isObject(data.options[value])) {
|
||||||
|
Object.keys(data.options[value]).map(subValue => {
|
||||||
|
if (isEmpty(get(data, ['options', value, subValue]))) {
|
||||||
|
formErrors.push({ name: `options.${value}.${subValue}`, errors: [{ id: 'components.Input.error.validation.required' }] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value !== 'response_email' && isEmpty(get(data, ['options', value]))) {
|
||||||
|
formErrors.push({ name: `options.${value}`, errors: [{ id: 'components.Input.error.validation.required' }] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user