minvalue validation react admin

Solutions on MaxInterview for minvalue validation react admin by the best coders in the world

showing results for - "minvalue validation react admin"
Samy
11 Nov 2017
1import React from 'react';
2import {
3    TabbedForm,
4    FormTab,
5    Edit,
6    Datagrid,
7    TextField,
8    DateField,
9    TextInput,
10    ReferenceManyField,
11    NumberInput,    
12    DateInput,
13    BooleanInput,
14    EditButton
15} from 'react-admin';
16
17export const PostEdit = (props) => (
18    <Edit {...props}>
19        <TabbedForm>
20            <FormTab label="summary">
21                <TextInput disabled label="Id" source="id" />
22                <TextInput source="title" validate={required()} />
23                <TextInput multiline source="teaser" validate={required()} />
24            </FormTab>
25            <FormTab label="body">
26                <RichTextInput source="body" validate={required()} addLabel={false} />
27            </FormTab>
28            <FormTab label="Miscellaneous">
29                <TextInput label="Password (if protected post)" source="password" type="password" />
30                <DateInput label="Publication date" source="published_at" />
31                <NumberInput source="average_note" validate={[ number(), minValue(0) ]} />
32                <BooleanInput label="Allow comments?" source="commentable" defaultValue />
33                <TextInput disabled label="Nb views" source="views" />
34            </FormTab>
35            <FormTab label="comments">
36                <ReferenceManyField reference="comments" target="post_id" addLabel={false}>
37                    <Datagrid>
38                        <TextField source="body" />
39                        <DateField source="created_at" />
40                        <EditButton />
41                    </Datagrid>
42                </ReferenceManyField>
43            </FormTab>
44        </TabbedForm>
45    </Edit>
46);
47