rails text_field_tag


Creates a standard text field; use these text fields to input smaller chunks of text like a username or a search query.

Options

  • :disabled – If set to true, the user will not be able to use this input.
  • :size – The number of visible characters that will fit in the input.
  • :maxlength – The maximum number of characters that the browser will allow the user to enter.
  • :placeholder – The text contained in the field by default which is removed when the field receives focus.
  • Any other key creates standard HTML attributes for the tag.

text_field_tag is from ActionView::Helpers::FormTagHelper, which states :

Provides a number of methods for creating form tags that doesn’t rely on an Active Record object assigned to the template like FormHelper does. Instead, you provide the names and values manually.

Since this is a helper that does not rely on an active record object, you cannot call this method for the “f” object. It’s a a helper method that should be called like this :

<%= text_field_tag "whatever you want to write" %> 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s