Class: Forma::BooleanField
- Inherits:
-
SimpleField
- Object
- Field
- SimpleField
- Forma::BooleanField
- Defined in:
- lib/forma/field.rb
Overview
Boolean field.
Instance Attribute Summary
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, #turbolink, #url, #value, #width
Instance Method Summary collapse
Methods inherited from SimpleField
#errors, #has_errors?, #initialize, #value
Methods inherited from Field
#action, #id, #initialize, #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
This class inherits a constructor from Forma::SimpleField
Instance Method Details
#edit_element(val) ⇒ Object
375 376 377 378 379 |
# File 'lib/forma/field.rb', line 375 def edit_element(val) e1 = el('input', attrs: { type: 'hidden', name: parameter_name, value: "0"}) e2 = el('input', attrs: { id: self.id, type: 'checkbox', name: parameter_name, checked: ('checked' if val), value: "1"}) el('span', children: [ e1, e2 ]) end |
#view_element(val) ⇒ Object
371 372 373 |
# File 'lib/forma/field.rb', line 371 def view_element(val) el('input', attrs: { type: 'checkbox', disabled: true, checked: ('checked' if val) }) end |