Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

142
Views
Antd switch not triggering onValuesChange when toggling?

I have a basic form:

<Form
  layout="vertical"
  form={form}
  onFinish={onSubmit}
  onValuesChange={onValueChanges}
>
  <Form.Item
    label="Foo"
    name="requirePassword"
    valuePropName="checked"
  >
    <Switch />

        {requirePasswordSettingDirty && (
          <span className={styles.requirePasswordWarning}>
            Required password
          </span>
        )}
  </Form.Item>
</Form>

When I click the switch, it doesn't trigger the callback onValueChanges. What am I missing?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Data binding is tied to a Form.Item with name key and wraps only an Input. Therefore if you have additional elements alongside the Input, such as a custom label element, you'll have to nest Form.Items.

 <Form.Item label="Foo" valuePropName="checked">
    <Form.Item name="requirePassword">
      <Switch />
    </Form.Item>
    {requirePasswordSettingDirty && <span>Required password</span>}
  </Form.Item>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!