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

Select Array validation rule don't work even if the attribute is defined as require #61

Closed
JDL747 opened this issue Feb 19, 2018 · 4 comments

Comments

@JDL747
Copy link
Contributor

JDL747 commented Feb 19, 2018

When using the selectArray ngRest attribute type, the validation rule doesn't work even if the attribute is defined as required.

Expected Result

On save or update, the form should show a message stating that the field cannot be empty

What do you get instead?

The form being save or update without any validation

@nadar nadar self-assigned this Mar 5, 2018
@nadar nadar added this to the 1.1.0 milestone Mar 5, 2018
@nadar nadar removed this from the 1.1.0 milestone Mar 29, 2018
@nadar
Copy link
Member

nadar commented Feb 26, 2019

@JDL747 could you please provide the validation rules you where using?

@JDL747
Copy link
Contributor Author

JDL747 commented Feb 26, 2019

rules
[['level'], 'integer'],

ngRestAttributeTypes
'level' => ['selectArray', 'data' => [1 => 'Amateur', 2 => 'Professionnel']],

@nadar
Copy link
Member

nadar commented Mar 20, 2019

@JDL747 have you tried to change the handling of empty values?

https://www.yiiframework.com/doc/guide/2.0/en/input-validation#handling-empty-inputs

@nadar
Copy link
Member

nadar commented Mar 20, 2019

I just tested - yes i can confirm this won't work out of the box until you set the isEmpty validator as "0" is not an empty value.

@nadar nadar closed this as completed in 101a31d Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants