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

[Bug Report] 字段使用x-visible切换时,重新输入会丢失字段问题 #4076

Open
1 task
007sair opened this issue Jan 23, 2024 · 1 comment
Open
1 task

Comments

@007sair
Copy link

007sair commented Jan 23, 2024

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

在“Topic”字段中随意输入值,然后选择其他“类型”字段,再次修改“Topci”字段,formValues中不会有topic字段

What is expected?

在选择不同的类型后,始终保留topic字段

What is actually happening?

topic字段会被删除,再输入时不会存在与values中

Package

@formily/react@2.3.1


这个场景我理解是一个很普遍的场景,public、private字段会受type字段改变visible值,这2个字段下都有某个相同的字段时,该字段会在切换后就不出现在values中了。

我尝试使用 x-hidden,但无法达到我的要求,因为我希望给到后端的字段是非冗余的。

期待您的回复!感谢!

@fzdfy
Copy link

fzdfy commented Feb 18, 2024

我也遇到过这个问题,整个表单好像不能有相同的字段,我自己的解决方案是把topic放到父层,用两个不同的内部变量_topic1, _topic2去渲染,然后 topic通过"x-value":"{{$values.type===x?$values._topic1:$values._topic2}}" 来设置值,最后提交的时候防止字段冗余把内部变量删掉。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants