Form controls are used to create an entity or collect information when the input data type needs to be verified.
2
const onFinish = (values) => {
6
<Form onFinish={onFinish} initialValues={{ username: 'wayne' }}>
7
<Row gutter={[10, 40]}>
12
help="user name must input"
13
rules={[{ required: true, message: 'Please input your username!' }]}
23
rules={[{ required: true, message: 'Please input your uid!' }]}
29
<FormItem name="group" label="Group" help="help content" tooltip="tooltip 内容 content">
34
<button type="submit">Submit</button>
The dynamic form can add the number of form items and customize the input content of the form items.
2
const [form] = useForm();
3
const getFieldErrors = () => {
4
console.log(form.validateFields());
6
const onFinish = (values) => {
9
const { Add, Trash } = KubeIcon;
11
<Form onFinish={onFinish} form={form}>
12
<FormList name="users">
13
{(fields, { add, remove }) => (
15
{fields.map(({ key, name, ...restField }) => (
16
<Row gutter={[10, 40]} key={key}>
20
name={[name, 'first']}
22
help="user name must input"
23
rules={[{ required: true, message: 'Please input your username!' }]}
34
rules={[{ required: true, message: 'Please input your uid!' }]}
40
<Button variant="text" onClick={() => remove(name)}>
48
<Button onClick={() => add()}>
56
<button type="button" onClick={getFieldErrors}>