Class: Lotus::Helpers::FormHelper::Form
- Inherits:
-
Object
- Object
- Lotus::Helpers::FormHelper::Form
- Defined in:
- lib/lotus/helpers/form_helper.rb
Overview
Form object
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
private
The form name.
-
#url ⇒ String
readonly
private
The form action.
-
#values ⇒ ::Hash
readonly
private
The form values.
Instance Method Summary collapse
-
#initialize(name, url, values = {}, attributes = {}) ⇒ Form
constructor
Initialize a form.
-
#verb ⇒ String
private
Return the method specified by the given attributes or fall back to the default value.
Constructor Details
#initialize(name, url, values = {}, attributes = {}) ⇒ Form
Initialize a form
It accepts a set of values that are used in combination with request params to autofill value
attributes for fields.
The keys of this Hash, MUST correspond to the structure of the (nested) fields of the form.
For a given input where the name
is ‘book`, Lotus will look for `:book` key in values.
If the current params have the same key, it will be PREFERRED over the given values.
For instance, if params.get('book.title')
equals to "TDD"
while values[:book].title
returns "No test"
, the first will win.
198 199 200 201 202 203 |
# File 'lib/lotus/helpers/form_helper.rb', line 198 def initialize(name, url, values = {}, attributes = {}) @name = name @url = url @values = values @attributes = attributes || {} end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the form name.
107 108 109 |
# File 'lib/lotus/helpers/form_helper.rb', line 107 def name @name end |
#url ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the form action.
113 114 115 |
# File 'lib/lotus/helpers/form_helper.rb', line 113 def url @url end |
#values ⇒ ::Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the form values.
119 120 121 |
# File 'lib/lotus/helpers/form_helper.rb', line 119 def values @values end |
Instance Method Details
#verb ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the method specified by the given attributes or fall back to the default value
214 215 216 |
# File 'lib/lotus/helpers/form_helper.rb', line 214 def verb @attributes.fetch(:method, DEFAULT_METHOD) end |