Padrino::Helpers::FormHelpers

Module: Padrino::Helpers::FormHelpers

Overview

Helpers related to producing form related tags and inputs into templates.

Defined Under Namespace

Modules: Errors, Options, Security

Constant Summary

DATETIME_ATTRIBUTES =
[:value, :max, :min].freeze
COLOR_CODE_REGEXP =
/\A#([0-9a-fA-F]{3}){1,2}\z/.freeze

Instance Method Summary

Instance Method Details

#button_tag(caption, options = {}) ⇒ String

Constructs a button input from the given options.

Examples:

button_tag "Cancel", :class => 'clear'

Parameters:

  • caption (String) — The caption for the button.
  • options (Hash) (defaults to: {}) — The html options for the input field.

Returns:

  • (String) — The html button based on the options specified.

#button_to(caption, url, options = {}) ⇒ String #button_to(url, options = {}, &block) ⇒ String

Creates a form containing a single button that submits to the URL.

Examples:

button_to 'Delete', url(:accounts_destroy, :id => account), :method => :delete, :class => :form
# Generates:
# <form class="form" action="/admin/accounts/destroy/2" method="post">
#   <input type="hidden" value="delete" name="_method" />
#   <input type="submit" value="Delete" />
# </form>

Overloads:

  • #button_to(caption, url, options = {}) ⇒ String

    Parameters:

    • caption (String) — The text caption.
    • url (String) — The url href.
    • options (Hash) (defaults to: {}) — The html options.
  • #button_to(url, options = {}, &block) ⇒ String

    Parameters:

    • url (String) — The url href.
    • options (Hash) (defaults to: {}) — The html options.
    • block (Proc) — The button content.

Parameters:

  • options (Hash) — a customizable set of options

Returns:

  • (String) — Form and button html with specified options.

#check_box_tag(name, options = {}) ⇒ Object

Constructs a check_box from the given options.

Examples:

check_box_tag :remember_me, :value => 'Yes'

#color_field_tag(name, options = {}) ⇒ Object

Constructs a color tag from the given options.

Examples:

color_field_tag('color', :value => "#ff0000")
color_field_tag('color', :value => "#f00")

Parameters:

  • name (String) — The name of the color field.
  • options (Hash) (defaults to: {}) — The html options for the color field.

Options Hash (options):

  • :value (String) — The value of the color field. See examples for details.

#date_field_tag(name, options = {}) ⇒ String

Constructs a date tag from the given options.

Examples:

date_field_tag('date_with_min_max', :min => DateTime.new(1993, 2, 24),
                                    :max => DateTime.new(2000, 4, 1))
date_field_tag('date_with_value', :value => DateTime.new(2000, 4, 1))

Parameters:

  • name (String) — The name of the date field.
  • options (Hash) (defaults to: {}) — The html options for the date field.

Options Hash (options):

  • :min (DateTime, String) — The min date time of the date field.
  • :max (DateTime, String) — The max date time of the date field.
  • :value (DateTime, String) — The value of the date field. See examples for details.

Returns:

  • (String) — The html date field

#datetime_field_tag(name, options = {}) ⇒ String

Constructs a datetime tag from the given options.

Examples:

datetime_field_tag('datetime_with_min_max', :min => DateTime.new(1993, 2, 24, 12, 30, 45),
                                            :max => DateTime.new(2000, 4, 1, 12, 0, 0))
datetime_field_tag('datetime_with_value', :value => DateTime.new(2000, 4, 1, 12, 0, 0))

Parameters:

  • name (String) — The name of the datetime field.
  • options (Hash) (defaults to: {}) — The html options for the datetime field.

Options Hash (options):

  • :min (DateTime, String) — The min date time of the datetime field.
  • :max (DateTime, String) — The max date time of the datetime field.
  • :value (DateTime, String) — The value of the datetime field. See examples for details.

Returns:

  • (String) — The html datetime field

#datetime_local_field_tag(name, options = {}) ⇒ String

Constructs a datetime-local tag from the given options.

Examples:

datetime_local_field_tag('datetime_local_with_min_max', :min => DateTime.new(1993, 2, 24, 12, 30, 45),
                                                        :max => DateTime.new(2000, 4, 1, 12, 0, 0))
datetime_local_field_tag('datetime_local_with_value', :value => DateTime.new(2000, 4, 1, 12, 0, 0))

Parameters:

  • name (String) — The name of the datetime local field.
  • options (Hash) (defaults to: {}) — The html options for the datetime-local field.

Options Hash (options):

  • :min (DateTime, String) — The min date time of the datetime-local field.
  • :max (DateTime, String) — The max date time of the datetime-local field.
  • :value (DateTime, String) — The value of the datetime field. See examples for details.

Returns:

  • (String) — The html datetime-local field

#email_field_tag(name, options = {}) ⇒ String

Creates an email field input with the given name and options.

Examples:

email_field_tag :email, :placeholder => 'you@example.com'
# => <input name="email" placeholder="you@example.com" type="email" />

email_field_tag :email, :value => 'padrinorb@gmail.com', :readonly => true
# => <input name="email" value="padrinorb@gmail.com" readonly type="email" />

Parameters:

  • name (Symbol) — The name of the input to create.
  • options (Hash) (defaults to: {}) — The HTML options to include in this field.

Options Hash (options):

  • :id (String) — Specifies a unique identifier for the field.
  • :class (String) — Specifies the stylesheet class of the field.
  • :name (String) — Specifies the name of the field.
  • :accesskey (String) — Specifies a shortcut key to access the field.
  • :tabindex (Integer) — Specifies the tab order of the field.
  • :maxlength (Integer) — Specifies the maximum length, in characters, of the field.
  • :size (Integer) — Specifies the width, in characters, of the field.
  • :placeholder (String) — Specifies a short hint that describes the expected value of the field.
  • :hidden (Boolean) — Specifies whether or not the field is hidden from view.
  • :spellcheck (Boolean) — Specifies whether or not the field should have it's spelling and grammar checked for errors.
  • :draggable (Boolean) — Specifies whether or not the field is draggable. (true, false, :auto).
  • :pattern (String) — Specifies the regular expression pattern that the field's value is checked against.
  • :autocomplete (Symbol) — Specifies whether or not the field should have autocomplete enabled. (:on, :off).
  • :autofocus (Boolean) — Specifies whether or not the field should automatically get focus when the page loads.
  • :required (Boolean) — Specifies whether or not the field is required to be completed before the form is submitted.
  • :readonly (Boolean) — Specifies whether or not the field is read only.
  • :disabled (Boolean) — Specifies whether or not the field is disabled.

Returns:

  • (String) — Generated HTML with specified options.

#field_set_tag(legend = nil, options = {}, &block) ⇒ String #field_set_tag(options = {}, &block) ⇒ String

Constructs a field_set to group fields with given options.

Examples:

field_set_tag(:class => "office-set") { }
field_set_tag("Office", :class => 'office-set') { }

Overloads:

  • #field_set_tag(legend = nil, options = {}, &block) ⇒ String

    Parameters:

    • legend (String) (defaults to: nil) — The legend caption for the fieldset
    • options (Hash) (defaults to: {}) — The html options for the fieldset.
    • block (Proc) — The content inside the fieldset.
  • #field_set_tag(options = {}, &block) ⇒ String

    Parameters:

    • options (Hash) (defaults to: {}) — The html options for the fieldset.
    • block (Proc) — The content inside the fieldset.

Returns:

  • (String) — The html for the fieldset tag based on given options.

#fields_for(object, options = {}, &block) ⇒ String

Constructs form fields for an object using given or default form_builder. Used within an existing form to allow alternate objects within one form.

Examples:

fields_for @user.assignment do |assignment| ... end
fields_for :assignment do |assigment| ... end

Parameters:

  • object (Object) — The object for which the fields are being built.
  • options (Hash) (defaults to: {}) — The settings associated with these fields. Accepts HTML options.
  • block (Proc) — The content inside this set of fields.

Returns:

  • (String) — The html fields with the specified options.

#file_field_tag(name, options = {}) ⇒ Object

Constructs a file field input from the given options.

Examples:

file_field_tag :photo, :class => 'long'

#form_for(object, url, options = {}, &block) {|AbstractFormBuilder| ... } ⇒ String

Constructs a form for object using given or default form_builder.

Examples:

form_for :user, '/register' do |f| ... end
form_for @user, '/register', :id => 'register' do |f| ... end
form_for @user, '/register', :as => :customer do |f| ... end

Parameters:

  • object (Object) — The object for which the form is being built.
  • URL (String) — The url this form will submit to.
  • options (Hash) (defaults to: {}) — The settings associated with this form. Accepts a :namespace option that will be prepended to the id attributes of the form's elements. Also accepts HTML options.
  • block (Proc) — The fields and content inside this form.
  • settings (Hash) — a customizable set of options

Yields:

  • (AbstractFormBuilder) — The form builder used to compose fields.

Returns:

  • (String) — The html object-backed form with the specified options and input fields.

#form_tag(url, options = {}, &block) ⇒ String

Constructs a form without object based on options.

Examples:

form_tag '/register', :class => "registration_form" do ... end

Parameters:

  • url (String) — The URL this form will submit to.
  • options (Hash) (defaults to: {}) — The html options associated with this form.
  • block (Proc) — The fields and content inside this form.

Returns:

  • (String) — The HTML form with the specified options and input fields.

#hidden_field_tag(name, options = {}) ⇒ Object

Constructs a hidden field input from the given options.

Examples:

hidden_field_tag :session_key, :value => "__secret__"

#hidden_form_method_field(desired_method) ⇒ String

Returns the hidden method field for 'put' and 'delete' forms. Only 'get' and 'post' are allowed within browsers; 'put' and 'delete' are just specified using hidden fields with form action still 'put'.

Examples:

# Generate: <input name="_method" value="delete" />
hidden_form_method_field('delete')

Parameters:

  • desired_method (String) — The method this hidden field represents (i.e put or delete).

Returns:

  • (String) — The hidden field representing the desired_method for the form.

#image_submit_tag(source, options = {}) ⇒ String

Constructs a submit button from the given options.

Examples:

image_submit_tag 'form/submit.png'

Parameters:

  • source (String) — The source image path for the button.
  • options (Hash) (defaults to: {}) — The html options for the input field.

Returns:

  • (String) — The html image button based on the options specified.

#label_tag(name, options = {}, &block) ⇒ String

Constructs a label tag from the given options.

Examples:

label_tag :username, :class => 'long-label'
label_tag :username, :class => 'long-label' do ... end

Parameters:

  • name (String) — The name of the field to label.
  • options (Hash) (defaults to: {}) — The html options for this label.
  • block (Proc) — The content to be inserted into the label.

Options Hash (options):

  • :caption (Object) — The caption for this label.

Returns:

  • (String) — The html for this label with the given options.

#month_field_tag(name, options = {}) ⇒ String

Constructs a month tag from the given options.

Examples:

month_field_tag('month_with_min_max', :min => DateTime.new(1993, 2, 24),
                                      :max => DateTime.new(2000, 4, 1))
month_field_tag('month_with_value', :value => DateTime.new(2000, 4, 1))

Parameters:

  • name (String) — The name of the month field.
  • options (Hash) (defaults to: {}) — The html options for the month field.

Options Hash (options):

  • :min (DateTime, String) — The min month time of the month field.
  • :max (DateTime, String) — The max month time of the month field.
  • :value (DateTime, String) — The value of the month field. See examples for details.

Returns:

  • (String) — The html month field

#number_field_tag(name, options = {}) ⇒ String

Creates a number field input with the given name and options.

Examples:

number_field_tag :quantity, :class => 'numeric'
# => <input name="quantity" class="numeric" type="number" />

number_field_tag :zip_code, :pattern => /[0-9]{5}/
# => <input name="zip_code" pattern="[0-9]{5}" type="number" />

number_field_tag :credit_card, :autocomplete => :off
# => <input name="credit_card" autocomplete="off" type="number" />

number_field_tag :age, :min => 18, :max => 120, :step => 1
# => <input name="age" min="18" max="120" step="1" type="number" />

Parameters:

  • name (Symbol) — The name of the input to create.
  • options (Hash) (defaults to: {}) — The HTML options to include in this field.

Options Hash (options):

  • :id (String) — Specifies a unique identifier for the field.
  • :class (String) — Specifies the stylesheet class of the field.
  • :name (String) — Specifies the name of the field.
  • :accesskey (String) — Specifies a shortcut key to access the field.
  • :tabindex (Integer) — Specifies the tab order of the field.
  • :min (Integer) — Specifies the minimum value of the field.
  • :max (Integer) — Specifies the maximum value of the field.
  • :step (Integer) — Specifies the legal number intervals of the field.
  • :hidden (Boolean) — Specifies whether or not the field is hidden from view.
  • :spellcheck (Boolean) — Specifies whether or not the field should have it's spelling and grammar checked for errors.
  • :draggable (Boolean) — Specifies whether or not the field is draggable. (true, false, :auto).
  • :pattern (String) — Specifies the regular expression pattern that the field's value is checked against.
  • :autocomplete (Symbol) — Specifies whether or not the field should have autocomplete enabled. (:on, :off).
  • :autofocus (Boolean) — Specifies whether or not the field should automatically get focus when the page loads.
  • :required (Boolean) — Specifies whether or not the field is required to be completeled before the form is submitted.
  • :readonly (Boolean) — Specifies whether or not the field is read only.
  • :disabled (Boolean) — Specifies whether or not the field is disabled.

Returns:

  • (String) — Generated HTML with specified options.

#password_field_tag(name, options = {}) ⇒ Object

Constructs a password field input from the given options.

Examples:

password_field_tag :password, :class => 'long'

#radio_button_tag(name, options = {}) ⇒ Object

Constructs a radio_button from the given options.

Examples:

radio_button_tag :remember_me, :value => 'true'

#range_field_tag(name, options = {}) ⇒ String

Constructs a range tag from the given options.

Examples:

range_field_tag('ranger_with_min_max', :min => 1, :max => 50)
range_field_tag('ranger_with_range', :range => 1..5)

Parameters:

  • name (String) — The name of the range field.
  • options (Hash) (defaults to: {}) — The html options for the range field.

Options Hash (options):

  • :min (Integer) — The min range of the range field.
  • :max (Integer) — The max range of the range field.
  • :range (range) — The range, in lieu of :min and :max. See examples for details.

Returns:

  • (String) — The html range field

#search_field_tag(name, options = {}) ⇒ String

Creates a search field input with the given name and options.

Examples:

search_field_tag :search, :placeholder => 'Search this website...'
# => <input name="search" placeholder="Search this website..." type="search" />

search_field_tag :search, :maxlength => 15, :class => ['search', 'string']
# => <input name="search" maxlength="15" class="search string" />

search_field_tag :search, :id => 'search'
# => <input name="search" id="search" type="search" />

search_field_tag :search, :autofocus => true
# => <input name="search" autofocus type="search" />

Parameters:

  • name (Symbol) — The name of the input to create.
  • options (Hash) (defaults to: {}) — The HTML options to include in this field.

Options Hash (options):

  • :id (String) — Specifies a unique identifier for the field.
  • :class (String) — Specifies the stylesheet class of the field.
  • :name (String) — Specifies the name of the field.
  • :accesskey (String) — Specifies a shortcut key to access the field.
  • :tabindex (Integer) — Specifies the tab order of the field.
  • :maxlength (Integer) — Specifies the maximum length, in characters, of the field.
  • :size (Integer) — Specifies the width, in characters, of the field.
  • :placeholder (String) — Specifies a short hint that describes the expected value of the field.
  • :hidden (Boolean) — Specifies whether or not the field is hidden from view.
  • :spellcheck (Boolean) — Specifies whether or not the field should have it's spelling and grammar checked for errors.
  • :draggable (Boolean) — Specifies whether or not the field is draggable. (true, false, :auto).
  • :pattern (String) — Specifies the regular expression pattern that the field's value is checked against.
  • :autocomplete (Symbol) — Specifies whether or not the field should have autocomplete enabled. (:on, :off).
  • :autofocus (Boolean) — Specifies whether or not the field should automatically get focus when the page loads.
  • :required (Boolean) — Specifies whether or not the field is required to be completed before the form is submitted.
  • :readonly (Boolean) — Specifies whether or not the field is read only.
  • :disabled (Boolean) — Specifies whether or not the field is disabled.

Returns:

  • (String) — Generated HTML with specified options.

#select_tag(name, options = {}) ⇒ String

Constructs a select from the given options.

Examples:

options = [['caption', 'value'], ['Green', 'green1'], ['Blue', 'blue1'], ['Black', "black1"]]
options = ['option', 'red', 'yellow' ]
select_tag(:favorite_color, :options => ['red', 'yellow'], :selected => 'green1')
select_tag(:country, :collection => @countries, :fields => [:name, :code], :include_blank => 'None')

# Optgroups can be generated using :grouped_options => (Hash or nested Array)
grouped_options = [['Friends',['Yoda',['Obiwan',1]]],['Enemies',['Palpatine',['Darth Vader',3]]]]
grouped_options = {'Friends' => ['Yoda',['Obiwan',1]],'Enemies' => ['Palpatine',['Darth Vader',3]]}
select_tag(:color, :grouped_options => [['warm',['red','yellow']],['cool',['blue', 'purple']]])

# Optgroups can be generated using the rails-style attribute hash.
grouped_options = {
  "Friends" => ["Yoda", ["Obiwan", 2, {:magister => 'no'}], {:lame => 'yes'}],
  "Enemies" => [["Palpatine", "Palpatine", {:scary => 'yes', :old => 'yes'}], ["Darth Vader", 3, {:disabled => true}]]
}
select_tag(:name, :grouped_options => grouped_options)

Parameters:

  • name (String) — The name of the input field.
  • options (Hash) (defaults to: {}) — The html options for the input field.

Options Hash (options):

  • :options (Array<String, Array>) — Explicit options to display in the select. Can be strings or string tuples.
  • :grouped_options (Array<Array>) — List of options for each group in the select. See examples for details.
  • :collection (Array<Object>) — Collection of objects used as options in the select.
  • :fields (Array<Symbol>) — The attributes used as “label” and “value” for each collection object.
  • :selected (String) — default: nil — The option value initially selected.
  • :include_blank (Boolean) — default: false — Include a blank option in the select.
  • :multiple (Boolean) — default: false — Allow multiple options to be selected at once.

Returns:

  • (String) — The HTML input field based on the options specified.

#submit_tag(options = {}) ⇒ String #submit_tag(caption, options = {}) ⇒ String

Constructs a submit button from the given options.

Examples:

submit_tag "Create", :class => 'success'
submit_tag :class => 'btn'

Overloads:

  • #submit_tag(options = {}) ⇒ String

    Parameters:

    • options (Hash) (defaults to: {}) — The html options for the input field.
  • #submit_tag(caption, options = {}) ⇒ String

    Parameters:

    • caption (String) — The caption for the submit button.
    • options (Hash) (defaults to: {}) — The html options for the input field.

Returns:

  • (String) — The html submit button based on the options specified.

#telephone_field_tag(name, options = {}) ⇒ String Also known as: phone_field_tag

Creates a telephone field input with the given name and options.

telephone_field_tag :cell_phone, :tabindex => 1
telephone_field_tag :work_phone, :tabindex => 2
telephone_field_tag :home_phone, :tabindex => 3

# => <input name="cell_phone" tabindex="1" type="tel" />
# => <input name="work_phone" tabindex="2" type="tel" />
# => <input name="home_phone" tabindex="3" type="tel" />

Examples:

telephone_field_tag :phone_number, :class => 'string'
# => <input name="phone_number" class="string" type="tel" />

Parameters:

  • name (Symbol) — The name of the input to create.
  • options (Hash) (defaults to: {}) — The HTML options to include in this field.

Options Hash (options):

  • :id (String) — Specifies a unique identifier for the field.
  • :class (String) — Specifies the stylesheet class of the field.
  • :name (String) — Specifies the name of the field.
  • :accesskey (String) — Specifies a shortcut key to access the field.
  • :tabindex (Integer) — Specifies the tab order of the field.
  • :maxlength (Integer) — Specifies the maximum length, in characters, of the field.
  • :size (Integer) — Specifies the width, in characters, of the field.
  • :placeholder (String) — Specifies a short hint that describes the expected value of the field.
  • :hidden (Boolean) — Specifies whether or not the field is hidden from view.
  • :spellcheck (Boolean) — Specifies whether or not the field should have it's spelling and grammar checked for errors.
  • :draggable (Boolean) — Specifies whether or not the field is draggable. (true, false, :auto).
  • :pattern (String) — Specifies the regular expression pattern that the field's value is checked against.
  • :autocomplete (Symbol) — Specifies whether or not the field should have autocomplete enabled. (:on, :off).
  • :autofocus (Boolean) — Specifies whether or not the field should automatically get focus when the page loads.
  • :required (Boolean) — Specifies whether or not the field is required to be completed before the form is submitted.
  • :readonly (Boolean) — Specifies whether or not the field is read only.
  • :disabled (Boolean) — Specifies whether or not the field is disabled.

Returns:

  • (String) — Generated HTML with specified options.

#text_area_tag(name, options = {}) ⇒ Object

Constructs a text area input from the given options.

Examples:

text_area_tag :username, :class => 'long', :value => "Demo?"

#text_field_tag(name, options = {}) ⇒ String

Creates a text field input with the given name and options.

Examples:

text_field_tag :first_name, :maxlength => 40, :required => true
# => <input name="first_name" maxlength="40" required type="text" />

text_field_tag :last_name, :class => 'string', :size => 40
# => <input name="last_name" class="string" size="40" type="text" />

text_field_tag :username, :placeholder => 'Your Username'
# => <input name="username" placeholder="Your Username" type="text" />

Parameters:

  • name (Symbol) — The name of the input to create.
  • options (Hash) (defaults to: {}) — The HTML options to include in this field.

Options Hash (options):

  • :id (String) — Specifies a unique identifier for the field.
  • :class (String) — Specifies the stylesheet class of the field.
  • :name (String) — Specifies the name of the field.
  • :accesskey (String) — Specifies a shortcut key to access the field.
  • :tabindex (Integer) — Specifies the tab order of the field.
  • :maxlength (Integer) — Specifies the maximum length, in characters, of the field.
  • :size (Integer) — Specifies the width, in characters, of the field.
  • :placeholder (String) — Specifies a short hint that describes the expected value of the field.
  • :hidden (Boolean) — Specifies whether or not the field is hidden from view.
  • :spellcheck (Boolean) — Specifies whether or not the field should have it's spelling and grammar checked for errors.
  • :draggable (Boolean) — Specifies whether or not the field is draggable. (true, false, :auto).
  • :pattern (String) — Specifies the regular expression pattern that the field's value is checked against.
  • :autocomplete (Symbol) — Specifies whether or not the field should have autocomplete enabled. (:on, :off).
  • :autofocus (Boolean) — Specifies whether or not the field should automatically get focus when the page loads.
  • :required (Boolean) — Specifies whether or not the field is required to be completed before the form is submitted.
  • :readonly (Boolean) — Specifies whether or not the field is read only.
  • :disabled (Boolean) — Specifies whether or not the field is disabled.

Returns:

  • (String) — Generated HTML with specified options.

#time_field_tag(name, options = {}) ⇒ String

Constructs a time tag from the given options.

Examples:

time_field_tag('time_with_min_max', :max => Time.new(1993, 2, 24, 1, 19, 12),
                                    :min => Time.new(2008, 6, 21, 13, 30, 0))
time_field_tag('time_with_value', :value => Time.new(2008, 6, 21, 13, 30, 0))

Parameters:

  • name (String) — The name of the time field.
  • options (Hash) (defaults to: {}) — The html options for the time field.

Options Hash (options):

  • :min (Time, DateTime, String) — The min time of the time field.
  • :max (Time, DateTime, String) — The max time of the time field.
  • :value (Time, DateTime, String) — The value of the time field. See examples for details.

Returns:

  • (String) — The html time field

#url_field_tag(name, options = {}) ⇒ String

Creates a URL field input with the given name and options.

Examples:

url_field_tag :favorite_website, :placeholder => 'http://padrinorb.com'
<input name="favorite_website" placeholder="http://padrinorb.com." type="url" />

url_field_tag :home_page, :class => 'string url'
<input name="home_page" class="string url", type="url" />

Parameters:

  • name (Symbol) — The name of the input to create.
  • options (Hash) (defaults to: {}) — The HTML options to include in this field.

Options Hash (options):

  • :id (String) — Specifies a unique identifier for the field.
  • :class (String) — Specifies the stylesheet class of the field.
  • :name (String) — Specifies the name of the field.
  • :accesskey (String) — Specifies a shortcut key to access the field.
  • :tabindex (Integer) — Specifies the tab order of the field.
  • :maxlength (Integer) — Specifies the maximum length, in characters, of the field.
  • :size (Integer) — Specifies the width, in characters, of the field.
  • :placeholder (String) — Specifies a short hint that describes the expected value of the field.
  • :hidden (Boolean) — Specifies whether or not the field is hidden from view.
  • :spellcheck (Boolean) — Specifies whether or not the field should have it's spelling and grammar checked for errors.
  • :draggable (Boolean) — Specifies whether or not the field is draggable. (true, false, :auto).
  • :pattern (String) — Specifies the regular expression pattern that the field's value is checked against.
  • :autocomplete (Symbol) — Specifies whether or not the field should have autocomplete enabled. (:on, :off).
  • :autofocus (Boolean) — Specifies whether or not the field should automatically get focus when the page loads.
  • :required (Boolean) — Specifies whether or not the field is required to be completed before the form is submitted.
  • :readonly (Boolean) — Specifies whether or not the field is read only.
  • :disabled (Boolean) — Specifies whether or not the field is disabled.

Returns:

  • (String) — Generated HTML with specified options.

#week_field_tag(name, options = {}) ⇒ String

Constructs a week tag from the given options.

Examples:

week_field_tag('week_with_min_max', :min => DateTime.new(1993, 2, 24),
                                    :max => DateTime.new(2000, 4, 1))
week_field_tag('week_with_value', :value => DateTime.new(2000, 4, 1))

Parameters:

  • name (String) — The name of the week field.
  • options (Hash) (defaults to: {}) — The html options for the week field.

Options Hash (options):

  • :min (DateTime, String) — The min week time of the week field.
  • :max (DateTime, String) — The max week time of the week field.
  • :value (DateTime, String) — The value of the week field. See examples for details.

Returns:

  • (String) — The html week field

© 2010–2016 Padrino
Licensed under the MIT License.
http://www.rubydoc.info/github/padrino/padrino-framework/Padrino/Helpers/FormHelpers

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部