Methods
#
B
C
D
E
F
G
H
L
M
N
R
S
T
Attributes
[RW] object_name
[RW] object
[RW] options
[R] multipart
[R] parent_builder
Class Public methods
_to_partial_path()
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1254
1254:       def self._to_partial_path
1255:         @_to_partial_path ||= name.demodulize.underscore.sub!(/_builder$/, '')
1256:       end
new(object_name, object, template, options, proc)
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1266
1266:       def initialize(object_name, object, template, options, proc)
1267:         @nested_child_index = {}
1268:         @object_name, @object, @template, @options, @proc = object_name, object, template, options, proc
1269:         @parent_builder = options[:parent_builder]
1270:         @default_options = @options ? @options.slice(:index, :namespace) : {}
1271:         if @object_name.to_s.match(/\[\]$/)
1272:           if object ||= @template.instance_variable_get("@#{Regexp.last_match.pre_match}") and object.respond_to?(:to_param)
1273:             @auto_index = object.to_param
1274:           else
1275:             raise ArgumentError, "object[] naming but object param and @object var don't exist or don't respond to to_param: #{object.inspect}"
1276:           end
1277:         end
1278:         @multipart = nil
1279:       end
Instance Public methods
button(value=nil, options={})

Add the submit button for the given form. When no value is given, it checks if the object is a new resource or not to create the proper label:

  <%= form_for @post do |f| %>
    <%= f.button %>
  <% end %>

In the example above, if @post is a new record, it will use “Create Post” as submit button label, otherwise, it uses “Update Post”.

Those labels can be customized using I18n, under the helpers.submit key and accept the %{model} as translation interpolation:

  en:
    helpers:
      button:
        create: "Create a %{model}"
        update: "Confirm changes to %{model}"

It also searches for a key specific for the given object:

  en:
    helpers:
      button:
        post:
          create: "Add %{model}"
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1403
1403:       def button(value=nil, options={})
1404:         value, options = nil, value if value.is_a?(Hash)
1405:         value ||= submit_default_value
1406:         @template.button_tag(value, options)
1407:       end
check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1325
1325:       def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
1326:         @template.check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value)
1327:       end
collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
     # File actionpack/lib/action_view/helpers/form_options_helper.rb, line 645
645:       def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
646:         @template.collection_select(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_options.merge(html_options))
647:       end
date_select(method, options = {}, html_options = {})
      # File actionpack/lib/action_view/helpers/date_helper.rb, line 1041
1041:       def date_select(method, options = {}, html_options = {})
1042:         @template.date_select(@object_name, method, objectify_options(options), html_options)
1043:       end
datetime_select(method, options = {}, html_options = {})
      # File actionpack/lib/action_view/helpers/date_helper.rb, line 1049
1049:       def datetime_select(method, options = {}, html_options = {})
1050:         @template.datetime_select(@object_name, method, objectify_options(options), html_options)
1051:       end
emitted_hidden_id?()
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1409
1409:       def emitted_hidden_id?
1410:         @emitted_hidden_id ||= nil
1411:       end
fields_for(record_name, record_object = nil, fields_options = {}, &block)
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1294
1294:       def fields_for(record_name, record_object = nil, fields_options = {}, &block)
1295:         fields_options, record_object = record_object, nil if record_object.is_a?(Hash) && record_object.extractable_options?
1296:         fields_options[:builder] ||= options[:builder]
1297:         fields_options[:parent_builder] = self
1298:         fields_options[:namespace] = fields_options[:parent_builder].options[:namespace]
1299: 
1300:         case record_name
1301:         when String, Symbol
1302:           if nested_attributes_association?(record_name)
1303:             return fields_for_with_nested_attributes(record_name, record_object, fields_options, block)
1304:           end
1305:         else
1306:           record_object = record_name.is_a?(Array) ? record_name.last : record_name
1307:           record_name   = ActiveModel::Naming.param_key(record_object)
1308:         end
1309: 
1310:         index = if options.has_key?(:index)
1311:           "[#{options[:index]}]"
1312:         elsif defined?(@auto_index)
1313:           self.object_name = @object_name.to_s.sub(/\[\]$/,"")
1314:           "[#{@auto_index}]"
1315:         end
1316:         record_name = "#{object_name}#{index}[#{record_name}]"
1317: 
1318:         @template.fields_for(record_name, record_object, fields_options, &block)
1319:       end
file_field(method, options = {})
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1338
1338:       def file_field(method, options = {})
1339:         self.multipart = true
1340:         @template.file_field(@object_name, method, objectify_options(options))
1341:       end
grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
     # File actionpack/lib/action_view/helpers/form_options_helper.rb, line 649
649:       def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
650:         @template.grouped_collection_select(@object_name, method, collection, group_method, group_label_method, option_key_method, option_value_method, objectify_options(options), @default_options.merge(html_options))
651:       end
hidden_field(method, options = {})
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1333
1333:       def hidden_field(method, options = {})
1334:         @emitted_hidden_id = true if method == :id
1335:         @template.hidden_field(@object_name, method, objectify_options(options))
1336:       end
label(method, text = nil, options = {}, &block)
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1321
1321:       def label(method, text = nil, options = {}, &block)
1322:         @template.label(@object_name, method, text, objectify_options(options), &block)
1323:       end
multipart=(multipart)
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1249
1249:       def multipart=(multipart)
1250:         @multipart = multipart
1251:         parent_builder.multipart = multipart if parent_builder
1252:       end
radio_button(method, tag_value, options = {})
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1329
1329:       def radio_button(method, tag_value, options = {})
1330:         @template.radio_button(@object_name, method, tag_value, objectify_options(options))
1331:       end
select(method, choices, options = {}, html_options = {})
     # File actionpack/lib/action_view/helpers/form_options_helper.rb, line 641
641:       def select(method, choices, options = {}, html_options = {})
642:         @template.select(@object_name, method, choices, objectify_options(options), @default_options.merge(html_options))
643:       end
submit(value=nil, options={})

Add the submit button for the given form. When no value is given, it checks if the object is a new resource or not to create the proper label:

  <%= form_for @post do |f| %>
    <%= f.submit %>
  <% end %>

In the example above, if @post is a new record, it will use “Create Post” as submit button label, otherwise, it uses “Update Post”.

Those labels can be customized using I18n, under the helpers.submit key and accept the %{model} as translation interpolation:

  en:
    helpers:
      submit:
        create: "Create a %{model}"
        update: "Confirm changes to %{model}"

It also searches for a key specific for the given object:

  en:
    helpers:
      submit:
        post:
          create: "Add %{model}"
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1370
1370:       def submit(value=nil, options={})
1371:         value, options = nil, value if value.is_a?(Hash)
1372:         value ||= submit_default_value
1373:         @template.submit_tag(value, options)
1374:       end
time_select(method, options = {}, html_options = {})
      # File actionpack/lib/action_view/helpers/date_helper.rb, line 1045
1045:       def time_select(method, options = {}, html_options = {})
1046:         @template.time_select(@object_name, method, objectify_options(options), html_options)
1047:       end
time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
     # File actionpack/lib/action_view/helpers/form_options_helper.rb, line 653
653:       def time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
654:         @template.time_zone_select(@object_name, method, priority_zones, objectify_options(options), @default_options.merge(html_options))
655:       end
to_model()
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1262
1262:       def to_model
1263:         self
1264:       end
to_partial_path()
      # File actionpack/lib/action_view/helpers/form_helper.rb, line 1258
1258:       def to_partial_path
1259:         self.class._to_partial_path
1260:       end