Ant-design: Handling form submits with Form component

Created on 12 Jan 2017  ·  3Comments  ·  Source: ant-design/ant-design

I am unsure on how to do form validation with the antd <Form/> component found here. The documentation specifies an onSubmit prop on the <Form/> component, which is passed an event. It then seems to trigger a function inside this.props.form. I am currently using the following code:

handleSubmit(e) {
   e.preventDefault();

  console.log('before' + e.target.value)

  this.props.validateFields((err, values) => {
  console.log('errors: ' + err)
  console.log(values)
    if (!err) {
      console.log('Received values of form: ', values);
    }
  });
}

<Form inline onSubmit={this.handleSubmit.bind(this)}>
    ....
</Form>
  1. I am unable to retrieve values from the event passed into the submit callback, as e.target.value returns undefined.

    1. In the call to this.props.validateFields(), as shown in the documentation, where are these values coming from?
Usage

Most helpful comment

@benjycui there is nothing useful answers in Stack overflow. and shut the fuck up the same replies to every questions of ant design MF. i can see you every git issue of ant design bullshit

All 3 comments

Ant Design team use GitHub issues to trace bugs or discuss plans of Ant Design. So, please don't ask usage questions here. You can try to ask questions in Stack Overflow or Segment Fault, then apply tag antd and react to your questions.

You should read documentation & FAQ and search issues before ask a question, THX!

It will be better if you read smart questions(提问的智慧).

@Orbyt Did you get the issue fixed? or do you have a stackoverflow question for this issue?

@benjycui there is nothing useful answers in Stack overflow. and shut the fuck up the same replies to every questions of ant design MF. i can see you every git issue of ant design bullshit

Was this page helpful?
0 / 5 - 0 ratings