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

More flexible validation for larger dropdowns #54

Open
sburkett opened this issue Oct 20, 2020 · 3 comments
Open

More flexible validation for larger dropdowns #54

sburkett opened this issue Oct 20, 2020 · 3 comments

Comments

@sburkett
Copy link

This was touched on by an issue last year ( #47 ), but I think it is worth revisiting since simply manually changing the column type/size of the schema isn't really an ideal approach.

A very common use-case is "country" . There are almost 200 of them in existence, and obviously they aren't all going to fit into the validation column, even using 2-byte country codes.

There are probably several ways to solve this, but one fairly quick and easy method might be to create an auxiliary hasMany table called dropdown_values or something. It might look something like:

COLUMN DATATYPE
id INT
fof_masquerade_field_id
value

So basically, it would just map to whatever the dropdown field id is.

Most of that is under-the-hood work, and would be transparent to the admin/user, of course.

To make it even better, there could be a quick-and-dirty CSV import option as well, perhaps, but that isn't really the core issue. It's the storage.

Just a thought!

@clarkwinkelmann
Copy link
Member

That's definitely a limitation of the system that was chosen here.

Since the AnswerValidator extends the Flarum validator, you could use custom code to listen for Flarum's Validating event and alter the validation rules. That way you can load the rules from somewhere else that's not restricted by a database column, or even use Laravel validation rules that aren't available through Masquerade like database-based validation.

@sburkett
Copy link
Author

True, though that seems like an awful lot of work for something that seems as if should be ready-made, as it were.

Instead, perhaps a custom extension that would bring that functionality into the fold. Or, perhaps less work would be to just do a PR to add the functionality into masquerade proper.

@clarkwinkelmann
Copy link
Member

Masquerade was never designed with dropdowns in mind.

Dropdowns are just a nice trick we introduced to make in: rules more user-friendly.

I don't really think we should be adding new features/tables to this extension at this time, we already have a hard time keeping up with maintaining the existing features 😅

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