From aade0a0412c3b8dfada4628487f6fb4c615f0060 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Tue, 29 Jul 2014 14:52:36 +0200 Subject: docs, cleanup mixed indents within `form_options_helper.rb` RDoc. [ci skip] This fixes the broken code block rendering and indents the examples within the parameter list. --- .../lib/action_view/helpers/form_options_helper.rb | 162 ++++++++++----------- 1 file changed, 81 insertions(+), 81 deletions(-) (limited to 'actionview/lib/action_view/helpers/form_options_helper.rb') diff --git a/actionview/lib/action_view/helpers/form_options_helper.rb b/actionview/lib/action_view/helpers/form_options_helper.rb index 528e2828a1..8ade7c6a74 100644 --- a/actionview/lib/action_view/helpers/form_options_helper.rb +++ b/actionview/lib/action_view/helpers/form_options_helper.rb @@ -14,81 +14,81 @@ module ActionView # # * :include_blank - set to true or a prompt string if the first option element of the select element is a blank. Useful if there is not a default value required for the select element. # - # select("post", "category", Post::CATEGORIES, {include_blank: true}) + # select("post", "category", Post::CATEGORIES, {include_blank: true}) # - # could become: + # could become: # - # + # # - # Another common case is a select tag for a belongs_to-associated object. + # Another common case is a select tag for a belongs_to-associated object. # - # Example with @post.person_id => 2: + # Example with @post.person_id => 2: # - # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, {include_blank: 'None'}) + # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, {include_blank: 'None'}) # - # could become: + # could become: # - # + # # # * :prompt - set to true or a prompt string. When the select element doesn't have a value yet, this prepends an option with a generic prompt -- "Please select" -- or the given prompt string. # - # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, {prompt: 'Select Person'}) + # select("post", "person_id", Person.all.collect {|p| [ p.name, p.id ] }, {prompt: 'Select Person'}) # - # could become: + # could become: # - # + # # - # Like the other form helpers, +select+ can accept an :index option to manually set the ID used in the resulting output. Unlike other helpers, +select+ expects this - # option to be in the +html_options+ parameter. + # * :index - like the other form helpers, +select+ can accept an :index option to manually set the ID used in the resulting output. Unlike other helpers, +select+ expects this + # option to be in the +html_options+ parameter. # - # select("album[]", "genre", %w[rap rock country], {}, { index: nil }) + # select("album[]", "genre", %w[rap rock country], {}, { index: nil }) # - # becomes: + # becomes: # - # + # # # * :disabled - can be a single value or an array of values that will be disabled options in the final output. # - # select("post", "category", Post::CATEGORIES, {disabled: 'restricted'}) + # select("post", "category", Post::CATEGORIES, {disabled: 'restricted'}) # - # could become: + # could become: # - # + # # - # When used with the collection_select helper, :disabled can also be a Proc that identifies those options that should be disabled. + # When used with the collection_select helper, :disabled can also be a Proc that identifies those options that should be disabled. # - # collection_select(:post, :category_id, Category.all, :id, :name, {disabled: lambda{|category| category.archived? }}) + # collection_select(:post, :category_id, Category.all, :id, :name, {disabled: lambda{|category| category.archived? }}) # - # If the categories "2008 stuff" and "Christmas" return true when the method archived? is called, this would return: - # + # If the categories "2008 stuff" and "Christmas" return true when the method archived? is called, this would return: + # # module FormOptionsHelper # ERB::Util can mask some helpers like textilize. Make sure to include them. @@ -461,21 +461,7 @@ module ActionView end # Returns a string of tags, like options_for_select, but - # wraps them with tags. - # - # Parameters: - # * +grouped_options+ - Accepts a nested array or hash of strings. The first value serves as the - # label while the second value must be an array of options. The second value can be a - # nested array of text-value pairs. See options_for_select for more info. - # Ex. ["North America",[["United States","US"],["Canada","CA"]]] - # * +selected_key+ - A value equal to the +value+ attribute for one of the tags, - # which will have the +selected+ attribute set. Note: It is possible for this value to match multiple options - # as you might have the same option in multiple groups. Each will then get selected="selected". - # - # Options: - # * :prompt - set to true or a prompt string. When the select element doesn't have a value yet, this - # prepends an option with a generic prompt - "Please select" - or the given prompt string. - # * :divider - the divider for the options groups. + # wraps them with tags: # # grouped_options = [ # ['North America', @@ -502,22 +488,36 @@ module ActionView # # # - # grouped_options = [ - # [['United States','US'], 'Canada'], - # ['Denmark','Germany','France'] - # ] - # grouped_options_for_select(grouped_options, nil, divider: '---------') + # Parameters: + # * +grouped_options+ - Accepts a nested array or hash of strings. The first value serves as the + # label while the second value must be an array of options. The second value can be a + # nested array of text-value pairs. See options_for_select for more info. + # Ex. ["North America",[["United States","US"],["Canada","CA"]]] + # * +selected_key+ - A value equal to the +value+ attribute for one of the tags, + # which will have the +selected+ attribute set. Note: It is possible for this value to match multiple options + # as you might have the same option in multiple groups. Each will then get selected="selected". # - # Possible output: - # - # - # - # - # - # - # - # - # + # Options: + # * :prompt - set to true or a prompt string. When the select element doesn't have a value yet, this + # prepends an option with a generic prompt - "Please select" - or the given prompt string. + # * :divider - the divider for the options groups. + # + # grouped_options = [ + # [['United States','US'], 'Canada'], + # ['Denmark','Germany','France'] + # ] + # grouped_options_for_select(grouped_options, nil, divider: '---------') + # + # Possible output: + # + # + # + # + # + # + # + # + # # # Note: Only the and tags are returned, so you still have to # wrap the output in an appropriate