Skip to content

Instantly share code, notes, and snippets.

@owendall
Created January 12, 2010 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save owendall/274764 to your computer and use it in GitHub Desktop.
Save owendall/274764 to your computer and use it in GitHub Desktop.
<include src="rapid" plugin="hobo"/>
<include src="taglibs/auto/rapid/cards"/>
<include src="taglibs/auto/rapid/pages"/>
<include src="taglibs/auto/rapid/forms"/>
<set-theme name="clean"/>
<def tag="app-name">My First App</def>
< --- pulled from
### Attributes
- `labels` - A hash that gives custom labels for the values of the enum.
Any values that do not have corresponding keys in this hash will get `value.titleize` as the label.
- `titleize` - Set to false to have the value itself (rather than `value.titleize`) be the default label. Default: true
- `first-option` - a string to be used for an extra option in the first position. E.g. "Please choose..."
- `first-value` - the value to be used with the `first-option`. Typically not used, meaning the option has a blank value.
-->
<def tag="input" for="HoboFields::EnumString" attrs="labels, titleize, first-option, first-value"><%
labels ||= {}
labels = HashWithIndifferentAccess.new(labels)
<--- changed the following line to default to false -->
titleize = false if titleize.nil?
<---- --->
options = this_type.values.map {|v| [labels.fetch(v, titleize ? this_type.translated_values[v].titleize : this_type.translated_values[v]), v] }
%>
<select name="#{param_name_for_this}" merge-attrs>
<option value="#{first_value}" unless="&first_option.nil?"><first-option/></option>
<%= options_for_select(options, this) %>
</select>
</def>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment