From be4a4cd38ff2c2db0f6b69bb72fb3557bd5a6e21 Mon Sep 17 00:00:00 2001 From: AvnerCohen Date: Mon, 29 Oct 2012 13:10:53 +0200 Subject: Hash Syntax to 1.9 related changes --- .../lib/action_view/helpers/form_tag_helper.rb | 108 ++++++++++----------- 1 file changed, 54 insertions(+), 54 deletions(-) (limited to 'actionpack/lib/action_view/helpers/form_tag_helper.rb') diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index f16e33d08d..0257a13bc4 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -10,7 +10,7 @@ module ActionView # FormHelper does. Instead, you provide the names and values manually. # # NOTE: The HTML options disabled, readonly, and multiple can all be treated as booleans. So specifying - # :disabled => true will give disabled="disabled". + # disabled: true will give disabled="disabled". module FormTagHelper extend ActiveSupport::Concern @@ -43,10 +43,10 @@ module ActionView # form_tag('/posts') # # =>
# - # form_tag('/posts/1', :method => :put) + # form_tag('/posts/1', method: :put) # # => ... ... # - # form_tag('/upload', :multipart => true) + # form_tag('/upload', multipart: true) # # => # # <%= form_tag('/posts') do -%> @@ -54,13 +54,13 @@ module ActionView # <% end -%> # # =>
# - # <%= form_tag('/posts', :remote => true) %> + # <%= form_tag('/posts', remote: true) %> # # =>
# - # form_tag('http://far.away.com/form', :authenticity_token => false) + # form_tag('http://far.away.com/form', authenticity_token: false) # # form without authenticity token # - # form_tag('http://far.away.com/form', :authenticity_token => "cf50faa3fe97702ca1ae") + # form_tag('http://far.away.com/form', authenticity_token: "cf50faa3fe97702ca1ae") # # form with custom authenticity token # def form_tag(url_for_options = {}, options = {}, &block) @@ -96,7 +96,7 @@ module ActionView # # => # - # select_tag "colors", "".html_safe, :multiple => true + # select_tag "colors", "".html_safe, multiple: true # # => # @@ -104,17 +104,17 @@ module ActionView # # => # - # select_tag "access", "".html_safe, :multiple => true, :class => 'form_input' + # select_tag "access", "".html_safe, multiple: true, class: 'form_input' # # => # - # select_tag "people", options_from_collection_for_select(@people, "id", "name"), :include_blank => true + # select_tag "people", options_from_collection_for_select(@people, "id", "name"), include_blank: true # # => # - # select_tag "people", options_from_collection_for_select(@people, "id", "name"), :prompt => "Select something" + # select_tag "people", options_from_collection_for_select(@people, "id", "name"), prompt: "Select something" # # => # - # select_tag "destination", "".html_safe, :disabled => true + # select_tag "destination", "".html_safe, disabled: true # # => # @@ -153,22 +153,22 @@ module ActionView # text_field_tag 'query', 'Enter your search query here' # # => # - # text_field_tag 'search', nil, :placeholder => 'Enter search term...' + # text_field_tag 'search', nil, placeholder: 'Enter search term...' # # => # - # text_field_tag 'request', nil, :class => 'special_input' + # text_field_tag 'request', nil, class: 'special_input' # # => # - # text_field_tag 'address', '', :size => 75 + # text_field_tag 'address', '', size: 75 # # => # - # text_field_tag 'zip', nil, :maxlength => 5 + # text_field_tag 'zip', nil, maxlength: 5 # # => # - # text_field_tag 'payment_amount', '$0.00', :disabled => true + # text_field_tag 'payment_amount', '$0.00', disabled: true # # => # - # text_field_tag 'ip', '0.0.0.0', :maxlength => 15, :size => 20, :class => "ip-input" + # text_field_tag 'ip', '0.0.0.0', maxlength: 15, size: 20, class: "ip-input" # # => def text_field_tag(name, value = nil, options = {}) tag :input, { "type" => "text", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys) @@ -186,7 +186,7 @@ module ActionView # label_tag 'name', 'Your name' # # => # - # label_tag 'name', nil, :class => 'small_label' + # label_tag 'name', nil, class: 'small_label' # # => def label_tag(name = nil, content_or_options = nil, options = nil, &block) if block_given? && content_or_options.is_a?(Hash) @@ -212,7 +212,7 @@ module ActionView # hidden_field_tag 'token', 'VUBJKB23UIVI1UU1VOBVI@' # # => # - # hidden_field_tag 'collected_input', '', :onchange => "alert('Input collected!')" + # hidden_field_tag 'collected_input', '', onchange: "alert('Input collected!')" # # => def hidden_field_tag(name, value = nil, options = {}) @@ -222,7 +222,7 @@ module ActionView # Creates a file upload field. If you are using file uploads then you will also need # to set the multipart option for the form tag: # - # <%= form_tag '/upload', :multipart => true do %> + # <%= form_tag '/upload', multipart: true do %> # <%= file_field_tag "file" %> # <%= submit_tag %> # <% end %> @@ -238,19 +238,19 @@ module ActionView # file_field_tag 'attachment' # # => # - # file_field_tag 'avatar', :class => 'profile_input' + # file_field_tag 'avatar', class: 'profile_input' # # => # - # file_field_tag 'picture', :disabled => true + # file_field_tag 'picture', disabled: true # # => # - # file_field_tag 'resume', :value => '~/resume.doc' + # file_field_tag 'resume', value: '~/resume.doc' # # => # - # file_field_tag 'user_pic', :accept => 'image/png,image/gif,image/jpeg' + # file_field_tag 'user_pic', accept: 'image/png,image/gif,image/jpeg' # # => # - # file_field_tag 'file', :accept => 'text/html', :class => 'upload', :value => 'index.html' + # file_field_tag 'file', accept: 'text/html', class: 'upload', value: 'index.html' # # => def file_field_tag(name, options = {}) text_field_tag(name, nil, options.update("type" => "file")) @@ -271,19 +271,19 @@ module ActionView # password_field_tag 'secret', 'Your secret here' # # => # - # password_field_tag 'masked', nil, :class => 'masked_input_field' + # password_field_tag 'masked', nil, class: 'masked_input_field' # # => # - # password_field_tag 'token', '', :size => 15 + # password_field_tag 'token', '', size: 15 # # => # - # password_field_tag 'key', nil, :maxlength => 16 + # password_field_tag 'key', nil, maxlength: 16 # # => # - # password_field_tag 'confirm_pass', nil, :disabled => true + # password_field_tag 'confirm_pass', nil, disabled: true # # => # - # password_field_tag 'pin', '1234', :maxlength => 4, :size => 6, :class => "pin_input" + # password_field_tag 'pin', '1234', maxlength: 4, size: 6, class: "pin_input" # # => def password_field_tag(name = "password", value = nil, options = {}) text_field_tag(name, value, options.update("type" => "password")) @@ -307,16 +307,16 @@ module ActionView # text_area_tag 'bio', @user.bio # # => # - # text_area_tag 'body', nil, :rows => 10, :cols => 25 + # text_area_tag 'body', nil, rows: 10, cols: 25 # # => # - # text_area_tag 'body', nil, :size => "25x10" + # text_area_tag 'body', nil, size: "25x10" # # => # - # text_area_tag 'description', "Description goes here.", :disabled => true + # text_area_tag 'description', "Description goes here.", disabled: true # # => # - # text_area_tag 'comment', nil, :class => 'comment_input' + # text_area_tag 'comment', nil, class: 'comment_input' # # => def text_area_tag(name, content = nil, options = {}) options = options.stringify_keys @@ -347,10 +347,10 @@ module ActionView # check_box_tag 'receive_email', 'yes', true # # => # - # check_box_tag 'tos', 'yes', false, :class => 'accept_tos' + # check_box_tag 'tos', 'yes', false, class: 'accept_tos' # # => # - # check_box_tag 'eula', 'accepted', false, :disabled => true + # check_box_tag 'eula', 'accepted', false, disabled: true # # => def check_box_tag(name, value = "1", checked = false, options = {}) html_options = { "type" => "checkbox", "name" => name, "id" => sanitize_to_id(name), "value" => value }.update(options.stringify_keys) @@ -372,10 +372,10 @@ module ActionView # radio_button_tag 'receive_updates', 'no', true # # => # - # radio_button_tag 'time_slot', "3:00 p.m.", false, :disabled => true + # radio_button_tag 'time_slot', "3:00 p.m.", false, disabled: true # # => # - # radio_button_tag 'color', "green", true, :class => "color_input" + # radio_button_tag 'color', "green", true, class: "color_input" # # => def radio_button_tag(name, value, checked = false, options = {}) html_options = { "type" => "radio", "name" => name, "id" => "#{sanitize_to_id(name)}_#{sanitize_to_id(value)}", "value" => value }.update(options.stringify_keys) @@ -392,7 +392,7 @@ module ActionView # # ==== Data attributes # - # * :confirm => 'question?' - If present the unobtrusive JavaScript + # * confirm: 'question?' - If present the unobtrusive JavaScript # drivers will provide a prompt with the question specified. If the user accepts, # the form is processed normally, otherwise no action is taken. # * :disable_with - Value of this parameter will be used as the value for a @@ -406,19 +406,19 @@ module ActionView # submit_tag "Edit this article" # # => # - # submit_tag "Save edits", :disabled => true + # submit_tag "Save edits", disabled: true # # => # - # submit_tag "Complete sale", :data => { :disable_with => "Please wait..." } + # submit_tag "Complete sale", data: { disable_with: "Please wait..." } # # => # - # submit_tag nil, :class => "form_submit" + # submit_tag nil, class: "form_submit" # # => # - # submit_tag "Edit", :class => "edit_button" + # submit_tag "Edit", class: "edit_button" # # => # - # submit_tag "Save", :data => { :confirm => "Are you sure?" } + # submit_tag "Save", data: { confirm: "Are you sure?" } # # => # def submit_tag(value = "Save changes", options = {}) @@ -454,7 +454,7 @@ module ActionView # # ==== Data attributes # - # * :confirm => 'question?' - If present, the + # * confirm: 'question?' - If present, the # unobtrusive JavaScript drivers will provide a prompt with # the question specified. If the user accepts, the form is # processed normally, otherwise no action is taken. @@ -467,14 +467,14 @@ module ActionView # button_tag # # => # - # button_tag(:type => 'button') do + # button_tag(type: 'button') do # content_tag(:strong, 'Ask me!') # end # # => # - # button_tag "Checkout", :data => { disable_with => "Please wait..." } + # button_tag "Checkout", data: { disable_with => "Please wait..." } # # => # def button_tag(content_or_options = nil, options = nil, &block) @@ -510,7 +510,7 @@ module ActionView # # ==== Data attributes # - # * :confirm => 'question?' - This will add a JavaScript confirm + # * confirm: 'question?' - This will add a JavaScript confirm # prompt with the question specified. If the user accepts, the form is # processed normally, otherwise no action is taken. # @@ -518,16 +518,16 @@ module ActionView # image_submit_tag("login.png") # # => # - # image_submit_tag("purchase.png", :disabled => true) + # image_submit_tag("purchase.png", disabled: true) # # => # - # image_submit_tag("search.png", :class => 'search_button') + # image_submit_tag("search.png", class: 'search_button') # # => # - # image_submit_tag("agree.png", :disabled => true, :class => "agree_disagree_button") + # image_submit_tag("agree.png", disabled: true, class: "agree_disagree_button") # # => # - # image_submit_tag("save.png", :data => { :confirm => "Are you sure?" }) + # image_submit_tag("save.png", data: { confirm: "Are you sure?" }) # # => def image_submit_tag(source, options = {}) options = options.stringify_keys @@ -557,7 +557,7 @@ module ActionView # <% end %> # # =>
Your details

# - # <%= field_set_tag nil, :class => 'format' do %> + # <%= field_set_tag nil, class: 'format' do %> #

<%= text_field_tag 'name' %>

# <% end %> # # =>

@@ -683,7 +683,7 @@ module ActionView # * Otherwise accepts the same options as text_field_tag. # # ==== Examples - # number_field_tag 'quantity', nil, :in => 1...10 + # number_field_tag 'quantity', nil, in: 1...10 # # => def number_field_tag(name, value = nil, options = {}) options = options.stringify_keys -- cgit v1.2.3