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

Validation error message not showing on parent form submit #47

Closed
ErikWittern opened this issue May 21, 2015 · 5 comments
Closed

Validation error message not showing on parent form submit #47

ErikWittern opened this issue May 21, 2015 · 5 comments

Comments

@ErikWittern
Copy link

I am using an ampersand-select-view within an ampersand-form-view like this:

new FormView({
  ...
  fields: [
    ...
    new SelectView({
      el: self.queryByHook('category'),
      name: 'category',
      options: categoryOptions,
      label: 'Main Category *',
      required: true,
      requiredMessage: "Please select a category."
    })
  ]
});

The select-view renders correctly. It is also considered in the form view's validation - selecting no option does prevent the submit. However, the error message is not displayed upon submit. The error is shown, though, if I select an entry and then deselect it again.

I use other ampersand-input-views in the same FormView, which work fine.

@cdaringe
Copy link
Member

hello, can you provide more input? are you by chance also using unselectedText? is there a falsy first value other than 0 for your top option? i tested this and saw the desired behavior. a requirebin would be helpful!

@ErikWittern
Copy link
Author

Hi Christopher, thanks for the reply! I tried to reproduce the error here: http://requirebin.com/?gist=ad163481d1910b99ed48. Interestingly, the message-container seems to get displayed after validation, but the message-text is not shown. Maybe I am just doing something stupid in consuming the view / setting up the form view?

@cdaringe
Copy link
Member

@ErikWittern, awesome. thanks man! so there are two issues.

  • adding the empty string '' to your categories list tells the select that '' is a valid option. please use unselectedText instead
  • there's a little bug where setting '' as unselectedText isn't honored. i'm pushing a bugfix for review now.

i ran a little demo with these updates and it seems to be working fine. i will push the PR soon

@ErikWittern
Copy link
Author

Fantastic, thank you very much, Christopher!

@ErikWittern
Copy link
Author

The update to v4.0.0 fixed my issue.

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