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

Document how to customize Field::Select option labels #2225

Merged
merged 1 commit into from
Jul 24, 2022
Merged

Document how to customize Field::Select option labels #2225

merged 1 commit into from
Jul 24, 2022

Conversation

cabe56
Copy link
Contributor

@cabe56 cabe56 commented Jul 16, 2022

Customizing select dropdowns helps keep the UI friendly without having to store lengthy values in a database column.

After looking through the customizing_dashboard docs I did not find a reference on how to do this. These resources helped me figure out how the select field's _form view handled option labels:

These are before/after screenshots of this PR:
Screen Shot 2022-07-15 at 7 13 08 PM
Screen Shot 2022-07-15 at 7 12 53 PM

Documenting support for this would imply supporting [[value, label]] as an input for :collection in Field::Select.with_options. If this is a concern I can write some tests to ensure this is accounted for in future releases.

@pablobm
Copy link
Collaborator

pablobm commented Jul 24, 2022

Uh, good point. I agree we should document this. I'm thinking that perhaps we should mention that it's the same options that would be passed to options_from_collection_for_select (as you correctly point out) with a link to its documentation. What do you think?

@pablobm
Copy link
Collaborator

pablobm commented Jul 24, 2022

Actually, I'm wrong. The code does assume things, with that :first/:last in the array case... OK. Let's leave it as you propose 👍

@pablobm pablobm merged commit 5c278d7 into thoughtbot:main Jul 24, 2022
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

Successfully merging this pull request may close these issues.

2 participants