Class: UserIconInput

Inherits:
SimpleForm::Inputs::Base
  • Object
show all
Defined in:
app/inputs/user_icon_input.rb

Overview

Output HTML for a username input form field.

The HTML generated is compatible with Bootstrap, and it prepends a user icon (from FontAwesome) before the input.

This class is intended to be used from simple_form forms like this:

<%= simple_form_for user, wrapper: :prepend do %>
  <%= f.input :email, as: :email_icon %>
  ...
<% end %>

Instance Method Summary collapse

Instance Method Details

#input(wrapper_options) ⇒ Object


15
16
17
18
# File 'app/inputs/user_icon_input.rb', line 15

def input(wrapper_options)
  input_html_options[:placeholder] ||= I18n.t 'simple_form.placeholders.user.username'
  "<span class=\"input-group-addon\"><i class=\"fa fa-fw fa-user\"></i></span>#{@builder.text_field(attribute_name, input_html_options)}".html_safe
end