我需要什么:
这是我的代码:
组件
export class FormCard extends Component {
handleSubmitWithRedirect = (redirect = this.props.redirect) => this.props.handleSubmit(values => this.props.save(values, redirect));
render () {
const {children, title, ...rest} = this.props;
return (
<div style={fieldStyle}>
<p style={titleStyle}>{title}</p>
<hr style={{height: '1px', border: 'none', backgroundColor: '#0000001f'}}/>
{Children.map(children, input => {
return input && (
// both thoses are get errors
cloneElement(input, {...rest})
// <div key={title} style={input.props.style}>
// <FormInput input={input} {...rest}/>
// </div>
)
})}
</div>
);
}
}
用法:
<Edit {...rest} title="建筑" actions={<PostEditActions/>} redirect='list'>
<SimpleForm validate={validateBuildingEdit} redirect="list">
<FormCard title='建筑信息'>
<TextInput source="name"/>
<TextInput source="year"/>
<TextInput source="fireCount"/>
<TextInput source="district"/>
<TextInput source="address"/>
</FormCard>
</SimpleForm>
</Edit>
所有这些人员都独立于redux-form
,似乎在div
之类的标签上使用了主题。