SelectArrayInput component required validation not working
santhosh1190 opened this issue · 0 comments
santhosh1190 commented
What you were expecting:
- I have two fields name called 'Name', 'City'. Here both fields are mandatory.
- Name is String & City is Array where I could choose multiple value.
- Name field used the 'TextInput' & City field used the 'SelectArrayInput' to choose multiple value.
- If I lose mouse focus on either field with nothing entered in fields, it should display error message like 'This field is required'.
What happened instead:
- When I lose focus from 'Name' field, it's displays error message.
- But I lose focus from 'City' fields without choose any value, It does not display any error message.
Related code:
const validateUserCreation = (values) => {
const errors = {};
if (!values.firstName) {
errors.firstName = ['The firstName is required'];
}
if (!values.cities) {
errors.cities= ['The city is required'];
}
return errors
};
export const UserCreate = (props) => (
<Create {...props}>
<SimpleForm validate={validateUserCreation}>
<TextInput label="First Name" source="firstName" />
<SelectArrayInput label="City" source="cities" choices={[
{ id: 'us', name: 'US' },
{ id: 'canada', name: 'Canada' }
]} />
</SimpleForm>
</Create>
);
Environment
- admin-on-rest - 1.3.3 version