forked from yuristrelets/react-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.jsx
More file actions
45 lines (40 loc) · 1.75 KB
/
form.jsx
File metadata and controls
45 lines (40 loc) · 1.75 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
import React from 'react';
import Form from '../../components/form';
class FormTest extends React.Component {
state = {
attributes: [
{ ref: 'name', label: 'Your Name', required: true, storage: true},
{ ref: 'description', multiline: true, label: 'Description', value: 'Doer'},
{ ref: 'birthdate', type: 'date', label: 'Birthdate'},
{ ref: 'years', type: 'number', label: 'Years'},
{ ref: 'twitter', label: 'Nickname', disabled: true},
{ ref: 'nomad', type: 'checkbox', label: 'Are you a nomad?', value: true},
{ ref: 'cow', type: 'checkbox', label: 'Are you a cow?', value: false},
{ ref: 'girl', type: 'checkbox', label: 'Are you a girl?', value: false, disabled: true},
{ ref: 'nomad_2', type: 'radio', label: 'Are you a nomad_2?', value: true},
{ ref: 'cow_2', type: 'radio', label: 'Are you a cow_2?', value: false},
{ ref: 'girl_2', type: 'radio', label: 'Are you a girl_2?', value: false, disabled: true},
{ ref: 'type_user', type: 'dropdown', label: 'Type of user', dataSource: [{value: 1, label: 'Normal'}, {value: 2, label: 'Root'}]},
{ type: 'submit', label: 'Send', style: 'primary anchor', disabled: true}
]
};
handleEvent = (type, event, form) => {
console.log(`[FORM.${type}]`, form.getValue());
};
render () {
return (
<section>
<h2>Form</h2>
<p>lorem ipsum...</p>
<Form
attributes={this.state.attributes}
storage="example-form"
onChange={this.handleEvent.bind(this, 'change')}
onError={this.handleEvent.bind(this, 'error')}
onValid={this.handleEvent.bind(this, 'valid')}
onSubmit={this.handleEvent.bind(this, 'submit')} />
</section>
);
}
}
export default FormTest;