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

Add checkValidation and isValid methods to window.PodsDFV #6898

Open
sc0ttkclark opened this issue Sep 11, 2022 · 1 comment · May be fixed by #7064
Open

Add checkValidation and isValid methods to window.PodsDFV #6898

sc0ttkclark opened this issue Sep 11, 2022 · 1 comment · May be fixed by #7064
Assignees
Labels
Type: Enhancement Enhancements to features that already exist, but are not major additions
Milestone

Comments

@sc0ttkclark
Copy link
Member

Problem to Solve

In places where we want to have integration with other forms and stop them from submitting if there are invalid/required fields -- we want to be able to get at this information from inside and outside of DFV.

Proposed Solution

Add checkValidation and isValid methods to window.PodsDFV so that they can be called:

  • Call validationMessages = window.PodsDFV.checkValidation( pod, itemId, formCounter ) before submit to run validation rules on current values (even if they have not changed and triggered a validation yet) and passes back the list of validationMessages that can be displayed in a modal/alert or in Block Editor publish message section or something later when we are ready for that
  • Call window.PodsDFV.isValid( pod, itemId, formCounter ) after running checkValidation() to determine whether the form should be allowed to continue being submitted

Possible Workaround

Manually going through the field values from what we get from window.PodsDFV.getFieldValuesWithConfigs() and checking whether required is on for the field and then confirming whether the field is empty.

It's not a great solution but that's what the jquery.pods.js uses right now as a workaround for the submit() handling.

Examples Elsewhere

No response

Screenshots / Screencast

No response

@sc0ttkclark sc0ttkclark added the Type: Enhancement Enhancements to features that already exist, but are not major additions label Sep 11, 2022
@sc0ttkclark sc0ttkclark added this to the Pods 2.9.4 milestone Sep 11, 2022
@sc0ttkclark sc0ttkclark modified the milestones: Pods 2.9.4, Pods 2.9.5 Sep 11, 2022
@sc0ttkclark sc0ttkclark modified the milestones: Pods 2.9.10, Pods 2.9.11 Oct 31, 2022
@sc0ttkclark sc0ttkclark modified the milestones: Pods 2.9.11, Pods 2.9.12 Jan 19, 2023
@sc0ttkclark sc0ttkclark modified the milestones: Pods 2.9.12, Pods 2.9.14 Mar 6, 2023
@sc0ttkclark sc0ttkclark modified the milestones: Pods 2.9.14, Pods 2.9.15 Mar 15, 2023
@sc0ttkclark sc0ttkclark assigned Shelob9 and unassigned zrothauser Apr 3, 2023
@sc0ttkclark
Copy link
Member Author

Not sure if it would be helpful here to also have a similar API to check if a field is conditionally visible (based on conditional logic).

Shelob9 added a commit that referenced this issue Apr 25, 2023
#6898

Co-authored-by: Scott Kingsley Clark <lol@scottkclark.com>
sc0ttkclark pushed a commit that referenced this issue Apr 25, 2023
sc0ttkclark added a commit that referenced this issue Apr 25, 2023
#6898

Co-authored-by: Scott Kingsley Clark <lol@scottkclark.com>
@sc0ttkclark sc0ttkclark assigned zrothauser and unassigned zrothauser Jun 21, 2023
@sc0ttkclark sc0ttkclark modified the milestones: Pods 3.0, Pods 3.1 Jun 25, 2023
@sc0ttkclark sc0ttkclark modified the milestones: Pods 3.1, Pods 3.2 Sep 4, 2023
@sc0ttkclark sc0ttkclark modified the milestones: Pods 3.2, Pods 3.3 Dec 11, 2023
@JoryHogeveen JoryHogeveen modified the milestones: Pods 3.3, Pods 3.2 Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Enhancements to features that already exist, but are not major additions
Projects
Status: 🚦 Next Focus
Development

Successfully merging a pull request may close this issue.

4 participants