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

Admin validation not rejecting empty 'select' fields with isRequired:true #3367

Closed
JoinThisBand opened this issue Aug 10, 2020 · 4 comments
Closed

Comments

@JoinThisBand
Copy link

Bug report

When creating a new item in the admin UI, field validation is not preventing form submission where a select field has isRequired:true, but a selection has not been made, e.g.

fruit: {
    type: Select,
    options: ['apple', 'pear', 'banana'],
    dataType: 'enum',
    isRequired: true
},

The user is able to submit the form without selecting a value for 'fruit' and a new item is not added to the list.

To Reproduce

Create a field with type:select, isRequired: true and some options, but no default value. Attempt to add a new item to the list from the admin UI, without selecting a value from this field.

Expected behaviour

The UI should alert the user that a required value for the select field has not been provided and prevent form submission.

System information

  • OS: macOS
  • Browser safari
  • @keystonejs/keystone 13.1.0
  • @keystonejs/fields 16.0.0

Additional context

Add any other context about the problem here.

@JoinThisBand JoinThisBand changed the title Admin validation not rejecting empty 'select' fields with isRequired:true Admin validation not rejecting empty select fields with isRequired:true Aug 10, 2020
@JoinThisBand JoinThisBand changed the title Admin validation not rejecting empty select fields with isRequired:true Admin validation not rejecting empty 'select' fields with isRequired:true Aug 10, 2020
@gautamsi
Copy link
Member

you should add a defaultValue if this has to have a value.

@JoinThisBand
Copy link
Author

I disagree; sometimes an interface needs to prompt the user to consider which option is correct.

A UI for a veterinary practise with a dropdown for gender set to male by default would definitely introduce data errors.

@stale
Copy link

stale bot commented Dec 8, 2020

It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :)

@stale stale bot added the needs-review label Dec 8, 2020
@bladey
Copy link
Contributor

bladey commented Apr 8, 2021

Keystone 5 has officially moved into active maintenance mode as we push towards the next major new version Keystone Next, you can find out more information about this transition here.

In an effort to sustain the project going forward, we're cleaning up and closing old issues such as this one. If you feel this issue is still relevant for Keystone Next, please let us know.

@bladey bladey closed this as completed Apr 8, 2021
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

3 participants