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隐藏字段类型校验问题 #413

Closed
szmaozi opened this issue Mar 24, 2021 · 0 comments
Closed

form隐藏字段类型校验问题 #413

szmaozi opened this issue Mar 24, 2021 · 0 comments

Comments

@szmaozi
Copy link

szmaozi commented Mar 24, 2021

Describe the bug

如果form定义一个隐藏字段(show: false), 并且该字段为非string类型,则会遇到校验不通过的问题(系统认为类型错误)。

Reproduction

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'id',
    required: true,
    component: 'InputNumber',
    show: false,
  },

解决方案:
更改components\Form\src\components\FormItem.vue
将判断条件更改:

function handleRules(): ValidationRule[] 
...
          // if (rule.required && component) { // 版本中的
          if (component) {  // 更改后
            if (!Reflect.has(rule, 'type')) {
              rule.type = 'string';
            }
...
@anncwb anncwb closed this as completed in 237f41d Mar 25, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant