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

Associative arrays not handled correctly #115

Closed
LostKobrakai opened this issue Mar 9, 2016 · 5 comments
Closed

Associative arrays not handled correctly #115

LostKobrakai opened this issue Mar 9, 2016 · 5 comments

Comments

@LostKobrakai
Copy link

I've noticed that the Form::IS_IN rule on select boxes is not handled correctly. I'd imagine being able to just put the same array I used to build up the select into the rule, but it's neither parsed to a json valid array nor flattened, so netteForms.js would be able to correctly validate the selectbox.

@milo
Copy link
Member

milo commented Mar 29, 2016

Could you please elaborate a little bit?

@LostKobrakai
Copy link
Author

I created a select input with the following array:

$data = ['a_1' => 'Test', 'a_2' => 'Test2'];

Using the Form::IS_IN rule with this $data array as filter won't work as it's testing against it's values and not the keys. In this case array_keys would be enough, but if optgroups are used one does need to flatten all keys out to get all the keys to test against.

@dg
Copy link
Member

dg commented Apr 1, 2016

Why are you adding this rule?

Anyway, this is correct behavior.

@dg dg closed this as completed Apr 1, 2016
@LostKobrakai
Copy link
Author

I'm adding the rule, because I want to make sure nobody has altered the select options to submit an invalid value.

@xificurk
Copy link
Contributor

xificurk commented Apr 7, 2016

@LostKobrakai That's already built-in feature of SelectBox control, you don't need to do that.

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

4 participants