wires up frontend for repeater, need to handle backend

This commit is contained in:
James
2018-12-09 19:56:30 -07:00
parent 9c5dfa2db0
commit c018db6839
4 changed files with 22 additions and 2 deletions

View File

@@ -10,6 +10,14 @@ class Repeater extends Component {
return (
<div className="field-repeater">
<Section heading={this.props.label}>
{this.props.initialValue.map((item, i) =>
React.Children.map(this.props.children, child =>
React.cloneElement(child, {
initialValue: item[child.props.name],
name: `${this.props.name}[${i}]${child.props.name}`
})
)
)}
</Section>
</div>
)

View File

@@ -27,6 +27,7 @@ const fieldType = (PassedComponent, type, validate, errors) => {
componentDidMount() {
let value = this.props.value ? this.props.value : '';
value = this.props.initialValue ? this.props.initialValue : value;
value = this.props.valueOverride ? this.props.valueOverride : value;
this.sendField(value);