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

Doc: no values param in onFormSubmit callback if not return in resolver #7031

Closed
1 of 4 tasks
wflixu opened this issue Dec 31, 2024 · 1 comment
Closed
1 of 4 tasks
Assignees
Labels
Component: Documentation Issue or pull request is related to Documentation Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@wflixu
Copy link

wflixu commented Dec 31, 2024

Describe the bug

In the Form documentation, I discovered that for submitHandler's args to include values, the resolver needs to return values - something I only learned by reading the source code. This important information should be noted in the documentation.

const resolver = ({ values }) => {
  const errors = {};
  console.log('resolver:', values);
  return {
    errors,
   // must return it if I want values arg in submit event handler
    values
  };

};

const onFormSubmit = ({ valid, states, values }) => {
  if (valid) {
    //  Here, I need to use the values from values to submit the form.
    console.log('submit:', values);
  }
};

Pull Request Link

No response

Reason for not contributing a PR

  • Lack of time
  • Unsure how to implement the fix/feature
  • Difficulty understanding the codebase
  • Other

Other Reason

I couldn’t find where the code is located in the documentation.

Reproducer

https://stackblitz.com/edit/gxphrkc5?file=src%2FApp.vue

Environment

In a normal macOS Chrome browser

Vue version

3.5.13

PrimeVue version

4.2.5

Node version

v20.18.1

Browser(s)

macOS 15.2, chrome 131.0.6778.205 (arm64)

Steps to reproduce the behavior

  1. Enter a piece of text in the input field
  2. click submit button.

Expected behavior

It would be great if this subtle point could be reflected in the documentation.

@wflixu wflixu added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 31, 2024
@ZyphenVisuals
Copy link

Additionally, in the Forms documentation for Resolvers, the custom resolver does not do this. Excerpt:

else if (schema === 'Custom') {
        resolver.value = ({ values }) => {
            const errors = {};

            if (!values.username) {
                errors.username = [{ message: 'Username is required.' }];
            }

            return {
                errors
            };
        };
    }

This caused a lot of confusion for me as well.

@mertsincan mertsincan added this to the 4.3.0 milestone Jan 6, 2025
@github-project-automation github-project-automation bot moved this to Review in PrimeVue Jan 6, 2025
@mertsincan mertsincan added Status: Pending Review Issue or pull request is being reviewed by Core Team and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jan 6, 2025
@mertsincan mertsincan self-assigned this Jan 6, 2025
@mertsincan mertsincan added Component: Documentation Issue or pull request is related to Documentation Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Jan 13, 2025
@github-project-automation github-project-automation bot moved this from Review to Done in PrimeVue Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Documentation Issue or pull request is related to Documentation Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
Status: Done
Development

No branches or pull requests

3 participants