We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
.
表单定义 JSON Schema 如下:
const schema = { type: "string", required: true, "x-decorator": "FormItem", "x-decorator-props": { asterisk: false }, "x-component": "Input", }
由于业务对 UI 的需求,希望无论字段是否必填,都不显示 *。 这里,期望当给 FormItem 提供了 asterisk 属性时,应当尊重该属性。
*
FormItem
asterisk
按照目前 FormItem 的实现,只要 required 为 true,就强制显示 *,而忽略 props.asterisk 的设置。
required
true
props.asterisk
目前 FormItem 的代码如下:
https://github.com/formilyjs/antd/blob/master/packages/components/src/form-item/index.tsx#L315-L323
const takeAsterisk = () => { if (field.required && field.pattern !== 'readPretty') { return true } if ('asterisk' in props) { return props.asterisk } return false }
应当交换两个 if 的顺序,当 props 中包含 asterisk 时,尊重 props,否则才自动设置。
if
props
@formily/antd-v5@1.1.0-beta.2
The text was updated successfully, but these errors were encountered:
可以提交个pr,我今晚发布
Sorry, something went wrong.
fix: form-item always take asterisk from props if provided
8da423e
alibaba/formily#3820
fix: form-item always take asterisk from props if provided (#13)
95179e8
alibaba/formily#3820 Co-authored-by: Zhang Cheng <chengzhang@natureself.cn>
Successfully merging a pull request may close this issue.
Reproduction link
.
Steps to reproduce
表单定义 JSON Schema 如下:
What is expected?
由于业务对 UI 的需求,希望无论字段是否必填,都不显示
*
。这里,期望当给
FormItem
提供了asterisk
属性时,应当尊重该属性。What is actually happening?
按照目前
FormItem
的实现,只要required
为true
,就强制显示*
,而忽略props.asterisk
的设置。目前 FormItem 的代码如下:
https://github.com/formilyjs/antd/blob/master/packages/components/src/form-item/index.tsx#L315-L323
应当交换两个
if
的顺序,当props
中包含asterisk
时,尊重props
,否则才自动设置。Package
@formily/antd-v5@1.1.0-beta.2
The text was updated successfully, but these errors were encountered: