Module: LesliView::Forms::Inputs
- Included in:
- Builder
- Defined in:
- lib/lesli_view/forms/inputs.rb
Instance Method Summary collapse
- #check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
- #email_field(method, options = {}) ⇒ Object
- #label(method, text = nil, options = {}) ⇒ Object
- #password_field(method, options = {}) ⇒ Object
- #submit(value = nil, options = {}) ⇒ Object
- #text_editor(method, options = {}) ⇒ Object
- #text_field(method, options = {}) ⇒ Object
Instance Method Details
#check_box(method, options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object
8 9 10 11 |
# File 'lib/lesli_view/forms/inputs.rb', line 8 def check_box(method, = {}, checked_value = "1", unchecked_value = "0") value = @object.send(method) super(method, , checked_value, unchecked_value) end |
#email_field(method, options = {}) ⇒ Object
28 29 30 31 |
# File 'lib/lesli_view/forms/inputs.rb', line 28 def email_field(method, = {}) value = @object.send(method) super(method, .merge(value: value, class: 'input')) end |
#label(method, text = nil, options = {}) ⇒ Object
4 5 6 |
# File 'lib/lesli_view/forms/inputs.rb', line 4 def label(method, text = nil, = {}) super(method, text, .merge(class: 'label')) end |
#password_field(method, options = {}) ⇒ Object
33 34 35 36 |
# File 'lib/lesli_view/forms/inputs.rb', line 33 def password_field(method, = {}) value = @object.send(method) super(method, .merge(value: value, class: 'input')) end |
#submit(value = nil, options = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/lesli_view/forms/inputs.rb', line 38 def submit(value=nil, = {}) # Extract and merge classes properly default_classes = "button is-primary" custom_classes = [:class] || "" merged_classes = "#{default_classes} #{custom_classes}".strip super(value, .merge(class: merged_classes)) end |
#text_editor(method, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/lesli_view/forms/inputs.rb', line 18 def text_editor(method, = {}) input_id = "#{object_name}_#{method}" editor_id = "#{input_id}_editor" hidden_field(method) + @template.content_tag("trix-toolbar", "", id: editor_id) + @template.content_tag("trix-editor", "", toolbar: editor_id, input: input_id) end |
#text_field(method, options = {}) ⇒ Object
13 14 15 16 |
# File 'lib/lesli_view/forms/inputs.rb', line 13 def text_field(method, = {}) value = @object.send(method) if @object super(method, .merge(value: value, class: 'input')) end |