Class: Hanami::Helpers::FormHelper::Form
- Inherits:
-
Object
- Object
- Hanami::Helpers::FormHelper::Form
- Defined in:
- lib/hanami/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`, Hanami 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.
200 201 202 203 204 205 |
# File 'lib/hanami/helpers/form_helper.rb', line 200 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.
108 109 110 |
# File 'lib/hanami/helpers/form_helper.rb', line 108 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.
114 115 116 |
# File 'lib/hanami/helpers/form_helper.rb', line 114 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.
120 121 122 |
# File 'lib/hanami/helpers/form_helper.rb', line 120 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
216 217 218 |
# File 'lib/hanami/helpers/form_helper.rb', line 216 def verb @attributes.fetch(:method, DEFAULT_METHOD) end |