Skip to content

Commit a2eea90

Browse files
author
bietkul
committed
Added meta prop support
1 parent af9867f commit a2eea90

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

src/FieldArray.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ class FieldArray extends React.Component {
1515
}
1616
}
1717
render() {
18-
const { strict, children, render } = this.props
18+
const { strict, children, render, meta } = this.props
19+
if (this.control) {
20+
this.control.meta = meta || {}
21+
}
1922
const FieldProps = {
2023
control: this.control,
2124
strict,
@@ -60,6 +63,7 @@ FieldArray.propTypes = {
6063
parent: PropTypes.oneOfType([
6164
PropTypes.instanceOf(FormArray),
6265
PropTypes.instanceOf(FormGroup)
63-
])
66+
]),
67+
meta: PropTypes.object
6468
}
6569
export default FieldArray

src/FieldControl.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
3-
import {
4-
FormControl,
5-
FormArray,
6-
FormGroup
7-
} from './model'
3+
import { FormControl, FormArray, FormGroup } from './model'
84
import configureControl from './configureControl'
95
import Field from './Field'
10-
116
export default class FieldControl extends React.Component {
127
constructor(props, context) {
138
super(props, context)
149
this.control = configureControl(props, context, 'FormControl')
1510
}
1611
componentWillReceiveProps(nextProps) {
17-
const {
18-
name
19-
} = nextProps
12+
const { name } = nextProps
2013
if (this.props.name !== name) {
2114
this.control = configureControl(nextProps, this.context, 'FormControl')
2215
}
2316
}
2417
render() {
25-
const {
26-
strict,
27-
children,
28-
render
29-
} = this.props
18+
const { strict, children, render, meta } = this.props
19+
if (this.control) {
20+
this.control.meta = meta || {}
21+
}
3022
const FieldProps = {
3123
control: this.control,
3224
strict,
@@ -67,11 +59,12 @@ FieldControl.propTypes = {
6759
parent: PropTypes.oneOfType([
6860
PropTypes.instanceOf(FormArray),
6961
PropTypes.instanceOf(FormGroup)
70-
])
62+
]),
63+
meta: PropTypes.object
7164
}
7265
FieldControl.contextTypes = {
7366
parentControl: PropTypes.oneOfType([
7467
PropTypes.instanceOf(FormArray),
7568
PropTypes.instanceOf(FormGroup)
7669
])
77-
}
70+
}

src/FieldGroup.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ class FieldGroup extends React.Component {
1515
}
1616
}
1717
render() {
18-
const { strict, children, render } = this.props
18+
const { strict, children, render, meta } = this.props
19+
if (this.control) {
20+
this.control.meta = meta || {}
21+
}
1922
const FieldProps = {
2023
control: this.control,
2124
strict,
@@ -62,6 +65,7 @@ FieldGroup.propTypes = {
6265
parent: PropTypes.oneOfType([
6366
PropTypes.instanceOf(FormArray),
6467
PropTypes.instanceOf(FormGroup)
65-
])
68+
]),
69+
meta: PropTypes.object
6670
}
6771
export default FieldGroup

0 commit comments

Comments
 (0)