forked from zabute/formsy-semantic-ui-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormExamples.js
More file actions
99 lines (92 loc) · 2.97 KB
/
FormExamples.js
File metadata and controls
99 lines (92 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import React, { Component } from 'react';
import { Form } from '../src';
import { Label } from 'semantic-ui-react';
const options = [
{ key: 'm', text: 'Male', value: 'male' },
{ key: 'f', text: 'Female', value: 'female' },
];
export default class FormExamples extends Component {
onValidSubmit = (formData) => alert(JSON.stringify(formData)); // eslint-disable-line
render() {
return (
<Form
ref={ ref => this.form = ref }
onValidSubmit={ this.onValidSubmit }
>
<Form.Group widths="equal">
<Form.Input
required
name="firstName"
label="First name"
placeholder="First name"
validations="isWords"
errorLabel={ <Label color="red" pointing/> }
validationErrors={{
isWords: 'No numbers or special characters allowed',
isDefaultRequiredValue: 'First Name is Required',
}}
/>
<Form.Input
name="lastName"
label="Last name"
placeholder="Last name"
required
validations="isWords"
errorLabel={ <Label color="red" pointing/> }
validationErrors={{
isWords: 'No numbers or special characters allowed',
isDefaultRequiredValue: 'Last Name is Required',
}}
/>
<Form.Select
name="gender"
label="Gender"
options={ options }
placeholder="Gender"
required
errorLabel={ <Label color="red" pointing/> }
validationErrors={{
isDefaultRequiredValue: 'Gender is Required',
}}
/>
</Form.Group>
<Form.RadioGroup
name="size"
required
label="Size"
errorLabel={ <Label color="red" pointing="left"/> }
validationErrors={{
isDefaultRequiredValue: 'Size is Required',
}}
>
<Form.Radio label="Small" value="sm"/>
<Form.Radio label="Medium" value="md"/>
<Form.Radio label="Large" value="lg"/>
</Form.RadioGroup>
<Form.TextArea
name="about"
label="About"
placeholder="Tell us more about you..."
required
errorLabel={ <Label color="red" pointing/> }
validationErrors={{
isDefaultRequiredValue: 'We need to know more about you',
}}
/>
<Form.Checkbox
name="terms"
label="I agree to the Terms and Conditions"
validations="isTrue"
errorLabel={ <Label color="red" pointing="left"/> }
validationErrors={{
isTrue: 'You\'ll have to agree to the Terms and Conditions',
}}
/>
<Form.Group>
<Form.Button content="Submit" color="green"/>
<Form.Button type="button" content="Reset" onClick={ () => this.form.reset() }/>
</Form.Group>
</Form>
);
}
}