-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathindex.js
More file actions
58 lines (57 loc) · 1.66 KB
/
Copy pathindex.js
File metadata and controls
58 lines (57 loc) · 1.66 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
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { View, Text } from 'native-base';
import GenerateForm from '../../formBuilder';
export default class FormField extends Component {
static propTypes = {
attributes: PropTypes.object,
theme: PropTypes.object,
updateValue: PropTypes.func,
autoValidation: PropTypes.bool,
customValidation: PropTypes.func,
customComponents: PropTypes.object,
}
constructor(props) {
super(props);
this.onValueChange = this.onValueChange.bind(this);
}
componentDidMount() {
this.props.updateValue(this.props.attributes.name, this.group.getValues());
}
onValueChange() {
this.props.updateValue(this.props.attributes.name, this.group.getValues());
}
handleChange(text) {
this.setState({
value: text,
}, () => this.props.updateValue(this.props.attributes.name, text));
}
render() {
const {
attributes,
theme,
autoValidation,
customValidation,
customComponents,
} = this.props;
return (
<View>
<View style={{ paddingHorizontal: 15, paddingVertical: 5 }}>
<Text style={{ fontWeight: '500', fontSize: 17 }}>{attributes.label}</Text>
</View>
<View style={{ paddingHorizontal: 10 }}>
<GenerateForm
ref={(c) => { this.group = c; }}
onValueChange={this.onValueChange}
autoValidation={autoValidation}
customValidation={customValidation}
customComponents={customComponents}
showErrors
fields={attributes.fields}
theme={theme}
/>
</View>
</View>
);
}
}