Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form] setFields方法调用不生效 #1215

Closed
liyongfen opened this issue Aug 3, 2022 · 2 comments · Fixed by #1226
Closed

[Form] setFields方法调用不生效 #1215

liyongfen opened this issue Aug 3, 2022 · 2 comments · Fixed by #1226
Assignees
Labels
in progress in progress

Comments

@liyongfen
Copy link

liyongfen commented Aug 3, 2022

tdesign-react 版本

0.38.0

重现链接

https://codesandbox.io/s/tdesign-react-demo-forked-jrkblb?file=/src/demo.jsx:406-431

重现步骤

点击页面【设置信息】按钮,【我的名字】字段没有出现error状态

期望结果

1、点击页面【设置信息】按钮,【我的名字】字段可以出现error状态
2、期望支持可以设置message,如formRef.current.setFields?.([{ name: "myname", status: "fail", message: "我是自定义错误信息" }]);

实际结果

【我的名字】字段没有出现error状态

框架版本

React 17

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

// demo 完整代码
import React, { useRef } from "react";
import {
Form,
Input,
Radio,
Checkbox,
Button,
MessagePlugin,
DatePicker
} from "tdesign-react";

const { FormItem } = Form;

export default function BaseForm() {
const formRef = useRef();

const onSubmit = (e) => {
console.log(e);
if (e.validateResult === true) {
MessagePlugin.info("提交成功");
}
};

const setData = () => {
formRef.current.setFields?.([{ name: "myname", status: "fail" }]);
console.log("getFieldsValue all: ", formRef.current.getFieldsValue?.(true));
};

const onReset = (e) => {
console.log(e);
MessagePlugin.info("重置成功");
};

const onValuesChange = (value) => {
console.log(value);
};

return (





<FormItem style={{ marginLeft: 100 }}>

提交

<Button theme="primary" onClick={setData} style={{ marginLeft: 12 }}>
设置信息

<Button type="reset" style={{ marginLeft: 12 }}>
重置



);
}

@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

👋 @liyongfen,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2022

♥️ 有劳 @ximendatie @cuijinyu @HQ-Lin @BaoTao1997 @yume316 尽快确认问题。
确认有效后将下一步计划和可能需要的时间回复给 @liyongfen

@honkinglin honkinglin added the in progress in progress label Aug 4, 2022
@honkinglin honkinglin linked a pull request Aug 4, 2022 that will close this issue
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants