Closed Spone closed 7 months ago
I'd like to have the following rendering:
# Model class Wine enum :color, {red: 0, white: 1, rose: 2}, suffix: true end
<%# View %> <%= f.combobox :color, Wine.colors, render_in: { partial: "colors/color" } %>
<%# Partial %> <span class="color-dot" style="--color: var(--#{color})"></span> <%= Wine.human_attribute_name("color.#{color}") %>
display
So instead of red I would see Rouge (no need to keep the colored dot, but that would be a nice plus.
red
Rouge
value
# Model class Wine enum :color, {red: 0, white: 1, rose: 2}, suffix: true def self.human_colors colors.to_h { |k, _v| [human_attribute_name("color.#{k}"), k] } end end
<%# View %> <%= f.combobox :color, Wine.human_colors, render_in: { partial: "colors/color" } %>
<%# Partial %> <span class="color-dot" style="--color: var(--#{value})"></span> <%= display %>
Great idea! Thanks! Implemented in https://github.com/josefarias/hotwire_combobox/pull/107. See PR for instructions.
Awesome!
Use case
I'd like to have the following rendering:
Current implementation
Problems
display
.So instead of
red
I would seeRouge
(no need to keep the colored dot, but that would be a nice plus.display
andvalue
instead of just the value: