instance method
file_field
Ruby on Rails 3.0.20
Since v2.2.3Signature
file_field(object_name, method, options = {})
Returns an file upload input tag tailored for accessing a specified attribute (identified by method) on an object assigned to the template (identified by object). Additional options on the input tag can be passed as a hash with options. These options will be tagged onto the HTML as an HTML element attribute as in the example shown.
Examples
file_field(:user, :avatar) # => <input type="file" id="user_avatar" name="user[avatar]" /> file_field(:post, :attached, :accept => 'text/html') # => <input type="file" id="post_attached" name="post[attached]" /> file_field(:attachment, :file, :class => 'file_input') # => <input type="file" id="attachment_file" name="attachment[file]" class="file_input" />
Parameters
-
object_namereq -
methodreq -
optionsopt = {}
Source
# File actionpack/lib/action_view/helpers/form_helper.rb, line 686
def file_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("file", options.update({:size => nil}))
end
Defined in actionpack/lib/action_view/helpers/form_helper.rb line 686
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Helpers::FormHelper