Method: SimpleForm::FormBuilder#input_field

Defined in:
lib/simple_form/form_builder.rb

- (Object) input_field(attribute_name, options = {})

Creates a input tag for the given attribute. All the given options are sent as :input_html.

Examples

simple_form_for @user do |f|
  f.input_field :name
end

This is the output html (only the input portion, not the form):

<input class="string required" id="user_name" maxlength="100"
   name="user[name]" type="text" value="Carlos" />


138
139
140
141
142
143
144
# File 'lib/simple_form/form_builder.rb', line 138

def input_field(attribute_name, options={})
  options = options.dup
  options[:input_html] = options.except(:as, :collection, :label_method, :value_method, *ATTRIBUTE_COMPONENTS)
  options = @defaults.deep_dup.deep_merge(options) if @defaults

  SimpleForm::Wrappers::Root.new(ATTRIBUTE_COMPONENTS + [:input], wrapper: false).render find_input(attribute_name, options)
end

Comments