Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to clear input value in antdesign form on submit

import React from 'react';
import { Button, Form, Input } from 'antd';

export default function MyFormComponent() {
  const [form] = Form.useForm();

  const submitForm = ({ name, favoriteColor }) => {
    console.log(name, favoriteColor);
    form.resetFields();
  };

  return (
    <Form
      form={form}
      labelCol={{ span: 6 }}
      wrapperCol={{ span: 12 }}
      onFinish={submitForm}
    >
      <Form.Item name="name" label="What is your name?">
        <Input />
      </Form.Item>
      <Form.Item name="favoriteColor" label="What is your favorite color?">
        <Input />
      </Form.Item>
      <Form.Item wrapperCol={{ offset: 6, span: 12 }}>
        <Button type="primary" htmlType="submit">
          Submit
        </Button>
      </Form.Item>
    </Form>
  );
}

Comment

how to clear input value in antdesign form on submit

<Form
            form={form}
            name="normal_login"
            className="login-form"
            initialValues={{
            remember: true,
            }}
/>

const onFinish=(values)=>{
     
      form.resetFields();
      let array1=[];
      if(Array.isArray(array1)){
        array1=values;
        localStorage.setItem(`${id}`,JSON.stringify({id,...array1}));
      }
  }
Comment

PREVIOUS NEXT
Code Example
Javascript :: getting values for metaboxes in wordpress 
Javascript :: chart.js src 
Javascript :: useformik 
Javascript :: ngif is string angular 
Javascript :: const is available in es6 
Javascript :: jquery replicate div on drag 
Javascript :: react cdn link 
Javascript :: type of angular 
Javascript :: populate example in mongoose 
Javascript :: remove falsy values from array with lodash 
Javascript :: object check null or empty 
Javascript :: sweet alert 2 react 
Javascript :: dayjs after 
Javascript :: angular material dropdown menu 
Javascript :: javascript https post 
Javascript :: Uncaught (in promise) DOMException: Failed to load because no supported source was found. 
Javascript :: loop javascript 
Javascript :: trigger keyboard event javascript 
Javascript :: ant design charts 
Javascript :: The element.InnerHTML Property 
Javascript :: vue electron name and icon 
Javascript :: npm install could not resolve peerDependencies 
Javascript :: discord.js ban user 
Javascript :: black adam release date 
Javascript :: react mui icons 
Javascript :: bookmarklets 
Javascript :: Mongoose filter by multiple fields 
Javascript :: create javascript array with 1 value 
Javascript :: how to convert a string to a mathematical expression programmatically javascript 
Javascript :: javascript screenshot 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =