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

215
Views
How to change value of select input which is inside a form balise (ant design)

I'm searching how to change the value of my select input inside of a form balise (with ant design library).

 let [value, setValue] = useState(null)

<Form.Item name="value" rules={[{ required: true, message: 'Veuillez choisir une valeur !' }]}
                   label="Type">
     <Select value={value} onChange={e => setValue(e)}>
         <Option value="pp">Personne physique</Option>
         <Option value="mp">Personne morale</Option>
     </Select>
</Form.Item>

<Button type="primary" onClick={setValue('pp')}>Click me</Button>

When i'm clicking, nothing happen, the value stay the old one.

But if I delete the <Form.Item> balise, it work correctly.

Any idea ?

Thank you

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

0

you can do like this

let [value, setValue] = useState(null)

const handleFormValuesChange = (changedValues) => {
  const formFieldName = Object.keys(changedValues)[0];
  if (formFieldName === "typeCeso") {
    setValue(changedValues[formFieldName]);
  }
};



<Form form={form} name="form" onFinish={onFinish} onValuesChange={handleFormValuesChange}>
  <Form.Item
  name="typeCeso"
  rules={[{ required: true, message: "Veuillez choisir une valeur !" }]}
  label="Type"
>
  <Select>
    <Option value="pp">Personne physique</Option>
    <Option value="mp">Personne morale</Option>
  </Select>
</Form.Item>
</Form>

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!