<input>
Provides an editable control tailored to the type of the object in context. <input> tags should be used within a <form>. <input> is a polymorphic tag which means that there are a variety of definitions, each one written for a particular type. For example there are inputs for text, boolean, password, date, datetime, integer, float, string and more.
Usage
The tag behaves as a regular HTML input if the type attribute is given:
<input type="text" name="my_input"/> -> Output is exactly as provided, untouched by Rapid
If no type attribute is given then the context is used. For example if the context is a blog post:
<input:title/> ->
<input id="blog_post[name]" class="string blog-post-name" type="text" value="My Blog Post" name="blog_post[name]"/>
<input:created_at/> ->
<select id="blog_post_created_at_year" name="blog_post[created_at][year]">...</select>
<select id="blog_post_created_at_month" name="blog_post[created_at][month]">...</select>
<select id="blog_post_created_at_day" name="blog_post[created_at][day]">...</select>
<input:description/> ->
<textarea class="text blog-post-description" id="blog_post[description]" name="blog_post[description]">...</textarea>
If the context is a belongs_to association, the <select-one> tag is used.
If the context is a has_many :through association, the polymorphic <collection-input> tag is used.
Attributes
-
no-edit: control what happens if
can_edit?is false. Can be one of:- view: render the current value using the
<view>tag - disable: render the input as normal, but add HTML’s
disabledattribute - skip: render nothing at all
- ignore: render the input normally. That is, don’t even perform the edit check.
- view: render the current value using the
<input for='HoboFields::EnumString'>
A <select> menu containing the values of an ‘enum string’.
Attributes
labels- A hash that gives custom labels for the values of the enum. Any values that do not have corresponding keys in this hash will getvalue.titleizeas the label.titleize- Set to false to have the value itself (rather thanvalue.titleize) be the default label. Default: truefirst-option- a string to be used for an extra option in the first position. E.g. “Please choose…”first-value- the value to be used with thefirst-option. Typically not used, meaning the option has a blank value.
<input for='text'>
A <textarea> input. Attributes are passed through to text_area_tag.
<input for='boolean'>
A checkbox plus a hidden-field. The hidden field trick comes from Rails - it means that when the checkbox is not checked, the parameter name is still submitted, with a ‘0’ value (the value is ‘1’ when the checkbox is checked)
<input for='password'>
A password input - <input type='password'>
<input for='date'>
A date picker, using the select_date helper from Rails
Attributes
- order: The order of the year, month and day menus. A comma separated string or an array. Default: “year, month, day”
Any other attributes are passed through to the select_date helper.
The menus default to the current date if the current value is nil.
<input for='time'>
A date/time picker, using the select_date helper from Rails
Attributes
- order: The order of the year, month and date menus. A comma separated string or an array. Default: “year, month, day, hour, minute, second”
Any other attributes are passed through to the select_date helper.
The menus default to the current time if the current value is nil.
<input for='datetime'>
A date/time picker, using the select_datetime helper from Rails
Attributes
- order: The order of the year, month and date menus. A comma separated string or an array. Default: “year, month, day, hour, minute”
Any other attributes are passed through to the select_datetime helper.
The menus default to the current time if the current value is nil.
<input for='integer'>
An <input type='text'> input.
<input for='float'>
An <input type='text'> input.
<input for='string'>
An <input type='text'> input.
<input for='big_integer'>
An <input type='text'> input.
<input for='Paperclip::Attachment'>
<input for='BigDecimal'>
An <input type='text'> input.