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.
197 198 199 200 201 202 |
# File 'lib/lotus/helpers/form_helper.rb', line 197 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.
106 107 108 |
# File 'lib/lotus/helpers/form_helper.rb', line 106 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.
112 113 114 |
# File 'lib/lotus/helpers/form_helper.rb', line 112 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.
118 119 120 |
# File 'lib/lotus/helpers/form_helper.rb', line 118 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
213 214 215 |
# File 'lib/lotus/helpers/form_helper.rb', line 213 def verb @attributes.fetch(:method, DEFAULT_METHOD) end |