-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
feat(components): [form] FormContext adds the getField method #14930
Conversation
👋 @cloudcome, seems like this is your first time contribution to element-plus.
|
Hello @cloudcome, thank you for contributing to element-plus, please see our guideline to see how to make contribution |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain your use case?
@btea 关注一下 |
@btea @ryuhangyeong 我们内部将 el-form 封装为 my-form,将 el-form-item 封装为 my-form-item 以便更好的接入内部的表单验证系统,它比内置的 async-validator 要更加的本地化,但在表单验证过程中却需要用到表单和字段元信息。这样的话,更多三方开发者可以更好的扩展 el-form 和 el-form-item。 We internally encapsulate el-form as my-form and el-form-item as my-form-item to better connect to the internal form validation system. It is more localized than the built-in async-validator. However, form and field meta-information is required during form validation. In this way, more third-party developers can better extend el-form and el-form-item. |
🧪 Playground Preview: https://element-plus.run/?pr=14930 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cloudcome Sorry for replying so late. This modification looks good.
@btea 期待这个 pr 能够被合并。 |
Please make sure these boxes are checked before submitting your PR, thank you!
dev
branch.Description
🤖[deprecated] Generated by Copilot at 36b5da1
This pull request enhances the form component and its items by adding a
getField
function to the parent form and afieldValue
property to the child items. These changes enable easier access and validation of the form values.Related Issue
Fixes #___.
Explanation of Changes
🤖[deprecated] Generated by Copilot at 36b5da1
fieldValue
property toform-item.vue
component to get the value of the form item based on itsprop
and the parent form'smodelValue
(link)getField
function toform.vue
component to get theFormItemContext
object of a child form item by itsprop
from thefields
array (link)getField
function to child form items through theFormContext
object returned by thesetup
function ofform.vue
and theuseForm
hook (link)getField
function to theFormContext
interface andfieldValue
property to theFormItemContext
interface intypes.ts
to define the types of the new properties and methods (link, link)