`
<Input
label="Retail price"
editMode
name="retail_price"
rules={[{ required: true, message: validationRequiredText('retail price') }]}
type="number"
min={1}
/>
` In this how can I update and Set the form values using the name="retail_price".
I tried on other answers on google but didnt get the expected out put.
CodePudding user response:
Modern browsers support native querySelectorAll so you can do:
document.querySelectorAll('[name="retail_price"]');
Hope this helps.
CodePudding user response:
you can use react-hook-form library to manage values of the input. here is offical documention
import React from "react";
import { useForm } from "react-hook-form";
export default function FormValidation() {
const {
register,
handleSubmit
} = useForm();
const onSubmit = (data) => {
console.log(data);
};
return (
<div>
<form
onSubmit={handleSubmit(onSubmit)}
>
<Input
placeholder="Retail price"
type="text"
{...register("retail_price"}
/>
<Button type="submit">Submit</Button>
</form>
</div>
);
}
CodePudding user response:
set value by name you must using form
const [form] = Form.useForm();
const onSubmit = () => {
form.setFieldsValue({ retail_price: 'Hi, man!' });
}
<Button type=""primary onClick={onSubmit}>submit example</Button>
<Form form={form}>
<Form.Item name="retail_price" label="Retail price" rules={[{ required: true, message: validationRequiredText('retail price') }]}>
<Input editMode type="number" min={1} />
</Form.Item>
</Form