Class: Forma::TextField
- Inherits:
-
SimpleField
- Object
- Field
- SimpleField
- Forma::TextField
- Defined in:
- lib/forma/field.rb
Overview
Text field.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Attributes inherited from Field
#actions, #after, #autofocus, #before, #child_model_name, #height, #hint, #i18n, #icon, #inline_hint, #label, #model, #model_name, #name, #parent, #readonly, #required, #tag, #url, #value, #width
Instance Method Summary collapse
- #edit_element(val) ⇒ Object
-
#initialize(h = {}) ⇒ TextField
constructor
A new instance of TextField.
- #view_element(val) ⇒ Object
Methods inherited from SimpleField
Methods inherited from Field
#action, #id, #localization_key, #localized_hint, #localized_label, #name_as_chain, #parameter_name, #to_html
Methods included from Html
Methods included from Utils
extract_value, number_format, #simple_value, singular_name
Constructor Details
#initialize(h = {}) ⇒ TextField
Returns a new instance of TextField.
294 295 296 297 298 |
# File 'lib/forma/field.rb', line 294 def initialize(h = {}) h = h.symbolize_keys @password = h[:password] super(h) end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
292 293 294 |
# File 'lib/forma/field.rb', line 292 def password @password end |
Instance Method Details
#edit_element(val) ⇒ Object
304 305 306 307 308 309 310 311 312 313 |
# File 'lib/forma/field.rb', line 304 def edit_element(val) el('input', attrs: { id: self.id, name: parameter_name, type: (password ? 'password' : 'text'), value: val.to_s, autofocus: @autofocus, style: { width: ("#{width}px" if width.present?) } }) end |
#view_element(val) ⇒ Object
300 301 302 |
# File 'lib/forma/field.rb', line 300 def view_element(val) el((@tag || 'span'), text: (password ? '******' : val.to_s), attrs: { id: self.id }) end |