module SimpleForm::Components::Suffix
Support for `suffix:` option when using the simple_form gem. When using the provided `simple_form.rb` initializer everything should be properly setup to make use of this input component.
## Usage
Render a field with the suffix CHF:
“`erb
<%= f.input :amount, suffix: 'CHF' %>
“`
Pass in custom HTML options to the suffix div:
“`erb
<%= f.input :amount, suffix: 'CHF', suffix_html: { class: 'red-text' } %>
“`
Public Instance Methods
suffix(_wrapper_options = nil)
click to toggle source
# File lib/mtl/simple_form/suffix.rb, line 24 def suffix(_wrapper_options = nil) return unless suffix? @suffix_tag ||= begin additional_classes << 'has-suffix' template.content_tag :div, suffix_label, suffix_html_options end end
Private Instance Methods
suffix?()
click to toggle source
# File lib/mtl/simple_form/suffix.rb, line 35 def suffix? suffix_label end
suffix_html_options()
click to toggle source
# File lib/mtl/simple_form/suffix.rb, line 43 def suffix_html_options suffix_html = options.fetch(:suffix_html, {}) suffix_html[:class] = [suffix_html[:class], 'suffix'].compact suffix_html end
suffix_label()
click to toggle source
# File lib/mtl/simple_form/suffix.rb, line 39 def suffix_label options[:suffix].presence end