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

Many values for controller or value mapping can get verbose #722

Open
paulodeon opened this issue Sep 14, 2023 · 0 comments
Open

Many values for controller or value mapping can get verbose #722

paulodeon opened this issue Sep 14, 2023 · 0 comments

Comments

@paulodeon
Copy link

I'm wrapping the https://tom-select.js.org/ library in stimulus and there are a lot of settings that I would like to set via data attributes. The problem is that this gets verbose very quickly

<%= f.select :covering_id_in, Employment.for_select, {}, { multiple: true, data: { controller: "tom-select", tom_select_color_value: "slate", tom_select_auto_submit_value: true, tom_select_placeholder_value: "Select instructor" } } %>

That's only with three values - the problem is that every value name is wrapped by controller_name_#{value_name}_value

A workaround is to pass an entire object which works but doesn't auto camelize the keys or provide default values

<%= f.select :covering_id_in, Employment.for_select, {}, { multiple: true, data: { controller: "tom-select", tom_select_settings_value: { color: "slate", auto_submit: true, placeholder: "Select Date Range" } } %>

Any suggestions for a better way of doing this would be appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant