/* eslint react/no-multi-comp:0, no-console:0 */ import { createForm } from '../index'; import BaseMixin from '../../_util/BaseMixin'; const Form1 = { mixins: [BaseMixin], props: { form: Object, }, data() { return { useInput: true, }; }, methods: { onSubmit(e) { e.preventDefault(); this.form.validateFields((error, values) => { if (!error) { console.log('ok', values); } else { console.log('error', error, values); } }); }, changeUseInput(e) { this.setState({ useInput: e.target.checked, }); }, }, render() { const { getFieldError, getFieldDecorator } = this.form; return (
); }, }; const Form2 = { mixins: [BaseMixin], props: { form: Object, }, data() { return { useInput: true, }; }, beforeMount() { const { getFieldDecorator } = this.form; this.nameDecorator = getFieldDecorator('name', { initialValue: '', rules: [ { required: true, message: "What's your name?", }, ], }); }, methods: { onSubmit(e) { e.preventDefault(); this.form.validateFields((error, values) => { if (!error) { console.log('ok', values); } else { console.log('error', error, values); } }); }, changeUseInput(e) { this.setState({ useInput: e.target.checked, }); }, }, render() { const { getFieldError } = this.form; return ( ); }, }; const Form3 = { mixins: [BaseMixin], props: { form: Object, }, data() { return { useInput: false, }; }, methods: { onSubmit(e) { e.preventDefault(); this.form.validateFields((error, values) => { if (!error) { console.log('ok', values); } else { console.log('error', error, values); } }); }, changeUseInput(e) { this.setState({ useInput: e.target.checked, }); }, }, render() { const { getFieldError, getFieldDecorator } = this.form; return ( ); }, }; const Form4 = { mixins: [BaseMixin], props: { form: Object, }, data() { return { useInput: true, }; }, methods: { onSubmit(e) { e.preventDefault(); this.form.validateFields((error, values) => { if (!error) { console.log('ok', values); } else { console.log('error', error, values); } }); }, changeUseInput(e) { this.setState({ useInput: e.target.checked, }); }, }, render() { const { getFieldError, getFieldDecorator } = this.form; return ( ); }, }; const WrappedForm1 = createForm()(Form1); const WrappedForm2 = createForm()(Form2); const WrappedForm3 = createForm()(Form3); const WrappedForm4 = createForm()(Form4); export default { render() { return (