1<Form
2 form={form}
3 name="normal_login"
4 className="login-form"
5 initialValues={{
6 remember: true,
7 }}
8/>
9
10const onFinish=(values)=>{
11
12 form.resetFields();
13 let array1=[];
14 if(Array.isArray(array1)){
15 array1=values;
16 localStorage.setItem(`${id}`,JSON.stringify({id,...array1}));
17 }
18 }
19
1import React from 'react';
2import { Button, Form, Input } from 'antd';
3
4export default function MyFormComponent() {
5 const [form] = Form.useForm();
6
7 const submitForm = ({ name, favoriteColor }) => {
8 console.log(name, favoriteColor);
9 form.resetFields();
10 };
11
12 return (
13 <Form
14 form={form}
15 labelCol={{ span: 6 }}
16 wrapperCol={{ span: 12 }}
17 onFinish={submitForm}
18 >
19 <Form.Item name="name" label="What is your name?">
20 <Input />
21 </Form.Item>
22 <Form.Item name="favoriteColor" label="What is your favorite color?">
23 <Input />
24 </Form.Item>
25 <Form.Item wrapperCol={{ offset: 6, span: 12 }}>
26 <Button type="primary" htmlType="submit">
27 Submit
28 </Button>
29 </Form.Item>
30 </Form>
31 );
32}
33
34