/* 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 (
) }, } const NewForm = createForm({ onFieldsChange (_, changedFields, allFields) { console.log('onFieldsChange: ', changedFields, allFields) }, onValuesChange (_, changedValues, allValues) { console.log('onValuesChange: ', changedValues, allValues) }, })(Form) export default { render () { return (