vbenjs / vue-vben-admin

A modern vue admin panel built with Vue3, Shadcn UI, Vite, TypeScript, and Monorepo. It's fast!
https://www.vben.pro
MIT License
25.4k stars 6.91k forks source link

Bug: 使用 useVbenForm 时,schema 中的表单项如果不设置 rules 字段,即使输入了值也不会在提交时获取到该值 #4487

Closed ChenWeihua123 closed 1 month ago

ChenWeihua123 commented 1 month ago

Version

Vben Admin V5

Describe the bug?

使用 useVbenForm 时,schema 中的表单项如果不设置 rules 字段,即使输入了值也不会在提交时获取到该值

Reproduction

官方仓库注册页随便删除一项中的 rules 即可复现

System Info

windows11

Relevant log output

No response

Validations

mynetfan commented 1 month ago

FormApivalidate返回的values就是校验成功的字段数据。如果你需要获取无需校验的表单数据,在validate后用getValuespackages\effects\common-ui\src\ui\authentication\register.vue第56行左右

const [Form, { getValues, validate }] = useVbenForm(
  reactive({
    commonConfig: {
      hideLabel: true,
      hideRequiredMark: true,
    },
    schema: computed(() => props.formSchema),
    showDefaultActions: false,
  }),
);

const router = useRouter();

async function handleSubmit() {
  const { valid } = await validate();
  if (valid) {
    const values = await getValues();
    emit('submit', values as { password: string; username: string });
  }
}
ChenWeihua123 commented 1 month ago

哦哦get了 非常感谢您的回复 ♥️