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

Useful Form instance modifications #29316

Open
1 task done
spencer741 opened this issue Feb 11, 2021 · 2 comments
Open
1 task done

Useful Form instance modifications #29316

spencer741 opened this issue Feb 11, 2021 · 2 comments
Labels

Comments

@spencer741
Copy link

spencer741 commented Feb 11, 2021

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

What problem does this feature solve?

This issue will cover four topics.

  1. Adding getAllFieldNames prop to useForm (form instance). [priority low]
  2. Modifying isFieldTouched and isFieldsTouched [priority high]
  3. Adding isFieldVisited and isFieldsVisited props. [priority high]
  4. Adding isFieldValidated and isFieldsValidated props [priority high]

Some more advanced (and useful) features could be implemented with the form instance.

  1. Adding getAllFieldNames prop to useForm (form instance).
    var listOfFieldNames = formInstance.getAllFieldNames();
    This would help reduce hard-coded attempts to build a list of field names. A list of field names is required for the majority of the form instance props. If a field is changed within the form, we usually face having to modify a hard-coded list if we use any of the form instance props. This might not be as important of a problem to address, but would drastically improve usability of the form instance. This would be a modification to rc/field-form I believe.
  2. Modifying isFieldTouched and isFieldsTouched
    While experimenting with the usage of the isFieldTouched and isFieldsTouched, I found that 'touched' in this context really means 'modified'. For example, if I tab through all of the fields on a form, isFieldsTouched will be false. I suggest that isFieldTouched and isFieldsTouched should be renamed to isFieldModified and isFieldsModified respectively. This makes more semantic sense when referencing functionality of this feature, which leads me to number 3.
  3. Adding isFieldVisited and isFieldsVisited props.
    Currently, there is no way to tell if a field has been visited (which is originally what I thought isFieldTouched did). Adding this prop to form instance would allow full semantic coverage of what was confusing about isFieldTouched. This prop would perhaps keep track of the blur event of each field and if it has fired (not if it has been modified or not).
  4. Adding isFieldValidated and isFieldsValidated props [priority high]
    This would allow a check if a field has been previously validated already.

What does the proposed API look like?

The API would be similar to how the form instance props work, just modifying functionality of isFieldTouched and isFieldsTouched as well as adding a getAllFieldNames, isFieldVisited, isFieldsVisited, isFieldValidated, and isFieldsValidated props.

@spencer741
Copy link
Author

Note: I can contribute to making this feature request possible. I might need some pointers on where to start since I haven't contributed to antd (or rather rc/field-form before).

@tempoeric
Copy link
Contributor

Hi is this deployed on the current antd version?

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

No branches or pull requests

2 participants