/* eslint react/no-multi-comp:0, no-console:0 */ import createForm from '../src/createDOMForm' const Form = { props: { form: Object, }, methods: { onSubmit (e) { e.preventDefault() console.log('Values of member[0].name.firstname and a[0][1].b.c[0]') console.log(this.form.getFieldsValue(['member[0].name.firstname', 'a[0][1].b.c[0]'])) console.log('Values of all fields') console.log(this.form.getFieldsValue()) this.form.validateFieldsAndScroll((error, values) => { if (!error) { console.log('ok', values) } else { console.log('error', error, values) } }) }, onChange (e) { console.log(e.target.value) }, setField () { this.form.setFieldsValue({ member: [ { name: { firstname: 'm1 first', lastname: 'm1 last', }, }, { name: { firstname: 'm2 first', lastname: 'm2 last', }, }, ], a: [ [undefined, { b: { c: ['Value of a[0][1].b.c[0]'], }, }], ], w: { x: { y: { z: ['Value of w.x.y.z[0]'], }, }, }, }) }, resetFields () { console.log('reset') this.form.resetFields() }, }, render () { const { getFieldDecorator, getFieldError } = this.form return (
Member 0 firstname
{getFieldDecorator('member[0].name.firstname', { initialValue: '', rules: [{ required: true, message: 'What\'s the member_0 firstname?', }], })( )}
{(getFieldError('member[0].name.firstname') || []).join(', ')}
Member 0 lastname
{getFieldDecorator('member[0].name.lastname', { initialValue: '', rules: [{ required: true, message: 'What\'s the member_0 lastname?', }], })( )}
{(getFieldError('member[0].name.firstname') || []).join(', ')}
Member 1 firstname
{getFieldDecorator('member[1].name.firstname', { initialValue: '', rules: [{ required: true, message: 'What\'s the member_1 fistname?', }], })( )}
{(getFieldError('member[1].name.firstname') || []).join(', ')}
Member 1 lastname
{getFieldDecorator('member[1].name.lastname', { initialValue: '', rules: [{ required: true, message: 'What\'s the member_1 lastname?', }], })( )}
{(getFieldError('member[1].name.firstname') || []).join(', ')}
a[0][1].b.c[0]
{getFieldDecorator('a[0][1].b.c[0]', { initialValue: '', rules: [{ required: true, message: 'What\'s a[0][1].b.c[0]?', }], })( )}
{(getFieldError('a[0][1].b.c[0]') || []).join(', ')}
w.x.y.z[0]
{getFieldDecorator('w.x.y.z[0]', { initialValue: '', rules: [{ required: true, message: 'What\'s w.x.y.z[0]?', }], })( )}
{(getFieldError('w.x.y.z[0]') || []).join(', ')}
) }, } const NewForm = createForm({ onFieldsChange (_, changedFields, allFields) { console.log('onFieldsChange: ', changedFields, allFields) }, onValuesChange (_, changedValues, allValues) { console.log('onValuesChange: ', changedValues, allValues) }, })(Form) export default { render () { return (

setFieldsValue

) }, }