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.
This commit is contained in:
Yves Senn 2014-07-29 14:52:36 +02:00
parent c5fc7b5564
commit aade0a0412
1 changed files with 81 additions and 81 deletions

View File

@ -14,81 +14,81 @@ module ActionView
#
# * <tt>:include_blank</tt> - 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:
#
# <select name="post[category]">
# <option></option>
# <option>joke</option>
# <option>poem</option>
# </select>
# <select name="post[category]">
# <option></option>
# <option>joke</option>
# <option>poem</option>
# </select>
#
# Another common case is a select tag for a <tt>belongs_to</tt>-associated object.
# Another common case is a select tag for a <tt>belongs_to</tt>-associated object.
#
# Example with @post.person_id => 2:
# Example with <tt>@post.person_id => 2</tt>:
#
# 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:
#
# <select name="post[person_id]">
# <option value="">None</option>
# <option value="1">David</option>
# <option value="2" selected="selected">Sam</option>
# <option value="3">Tobias</option>
# </select>
# <select name="post[person_id]">
# <option value="">None</option>
# <option value="1">David</option>
# <option value="2" selected="selected">Sam</option>
# <option value="3">Tobias</option>
# </select>
#
# * <tt>:prompt</tt> - 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:
#
# <select name="post[person_id]">
# <option value="">Select Person</option>
# <option value="1">David</option>
# <option value="2">Sam</option>
# <option value="3">Tobias</option>
# </select>
# <select name="post[person_id]">
# <option value="">Select Person</option>
# <option value="1">David</option>
# <option value="2">Sam</option>
# <option value="3">Tobias</option>
# </select>
#
# Like the other form helpers, +select+ can accept an <tt>:index</tt> 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.
# * <tt>:index</tt> - like the other form helpers, +select+ can accept an <tt>:index</tt> 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:
#
# <select name="album[][genre]" id="album__genre">
# <option value="rap">rap</option>
# <option value="rock">rock</option>
# <option value="country">country</option>
# </select>
# <select name="album[][genre]" id="album__genre">
# <option value="rap">rap</option>
# <option value="rock">rock</option>
# <option value="country">country</option>
# </select>
#
# * <tt>:disabled</tt> - 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:
#
# <select name="post[category]">
# <option></option>
# <option>joke</option>
# <option>poem</option>
# <option disabled="disabled">restricted</option>
# </select>
# <select name="post[category]">
# <option></option>
# <option>joke</option>
# <option>poem</option>
# <option disabled="disabled">restricted</option>
# </select>
#
# When used with the <tt>collection_select</tt> helper, <tt>:disabled</tt> can also be a Proc that identifies those options that should be disabled.
# When used with the <tt>collection_select</tt> helper, <tt>:disabled</tt> 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 <tt>archived?</tt> is called, this would return:
# <select name="post[category_id]">
# <option value="1" disabled="disabled">2008 stuff</option>
# <option value="2" disabled="disabled">Christmas</option>
# <option value="3">Jokes</option>
# <option value="4">Poems</option>
# </select>
# If the categories "2008 stuff" and "Christmas" return true when the method <tt>archived?</tt> is called, this would return:
# <select name="post[category_id]">
# <option value="1" disabled="disabled">2008 stuff</option>
# <option value="2" disabled="disabled">Christmas</option>
# <option value="3">Jokes</option>
# <option value="4">Poems</option>
# </select>
#
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 <tt><option></tt> tags, like <tt>options_for_select</tt>, but
# wraps them with <tt><optgroup></tt> tags.
#
# Parameters:
# * +grouped_options+ - Accepts a nested array or hash of strings. The first value serves as the
# <tt><optgroup></tt> label while the second value must be an array of options. The second value can be a
# nested array of text-value pairs. See <tt>options_for_select</tt> for more info.
# Ex. ["North America",[["United States","US"],["Canada","CA"]]]
# * +selected_key+ - A value equal to the +value+ attribute for one of the <tt><option></tt> 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 <tt>selected="selected"</tt>.
#
# Options:
# * <tt>:prompt</tt> - 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.
# * <tt>:divider</tt> - the divider for the options groups.
# wraps them with <tt><optgroup></tt> tags:
#
# grouped_options = [
# ['North America',
@ -502,22 +488,36 @@ module ActionView
# <option value="France">France</option>
# </optgroup>
#
# 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
# <tt><optgroup></tt> label while the second value must be an array of options. The second value can be a
# nested array of text-value pairs. See <tt>options_for_select</tt> for more info.
# Ex. ["North America",[["United States","US"],["Canada","CA"]]]
# * +selected_key+ - A value equal to the +value+ attribute for one of the <tt><option></tt> 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 <tt>selected="selected"</tt>.
#
# Possible output:
# <optgroup label="---------">
# <option value="US">United States</option>
# <option value="Canada">Canada</option>
# </optgroup>
# <optgroup label="---------">
# <option value="Denmark">Denmark</option>
# <option value="Germany">Germany</option>
# <option value="France">France</option>
# </optgroup>
# Options:
# * <tt>:prompt</tt> - 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.
# * <tt>:divider</tt> - 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:
# <optgroup label="---------">
# <option value="US">United States</option>
# <option value="Canada">Canada</option>
# </optgroup>
# <optgroup label="---------">
# <option value="Denmark">Denmark</option>
# <option value="Germany">Germany</option>
# <option value="France">France</option>
# </optgroup>
#
# <b>Note:</b> Only the <tt><optgroup></tt> and <tt><option></tt> tags are returned, so you still have to
# wrap the output in an appropriate <tt><select></tt> tag.