Module: Reins::View::Forms
- Included in:
- Controller, Reins::View
- Defined in:
- lib/reins/view/forms.rb
Instance Method Summary collapse
- #form_with(url:, method: :post, **attrs) ⇒ Object
- #hidden_field(name, value:, **attrs) ⇒ Object
- #label(name, text = nil, **attrs) ⇒ Object
- #submit(value = "Save", **attrs) ⇒ Object
- #text_area(name, value: "", **attrs) ⇒ Object
- #text_field(name, **attrs) ⇒ Object
Instance Method Details
#form_with(url:, method: :post, **attrs) ⇒ Object
6 7 8 |
# File 'lib/reins/view/forms.rb', line 6 def form_with(url:, method: :post, **attrs) format_open_tag(:form, action: url, method: method.to_s, **attrs) end |
#hidden_field(name, value:, **attrs) ⇒ Object
23 24 25 |
# File 'lib/reins/view/forms.rb', line 23 def hidden_field(name, value:, **attrs) format_self_close_tag(:input, type: "hidden", name: name.to_s, value: value.to_s, **attrs) end |
#label(name, text = nil, **attrs) ⇒ Object
27 28 29 30 |
# File 'lib/reins/view/forms.rb', line 27 def label(name, text = nil, **attrs) text ||= humanize(name.to_s) "<label for=\"#{name}\"#{format_form_attrs(attrs)}>#{text}</label>" end |
#submit(value = "Save", **attrs) ⇒ Object
19 20 21 |
# File 'lib/reins/view/forms.rb', line 19 def submit(value = "Save", **attrs) format_self_close_tag(:input, type: "submit", value: value.to_s, **attrs) end |
#text_area(name, value: "", **attrs) ⇒ Object
14 15 16 17 |
# File 'lib/reins/view/forms.rb', line 14 def text_area(name, value: "", **attrs) body = CGI.escapeHTML(value.to_s) format_open_tag(:textarea, name: name.to_s, **attrs).sub(/>\z/, ">#{body}</textarea>") end |
#text_field(name, **attrs) ⇒ Object
10 11 12 |
# File 'lib/reins/view/forms.rb', line 10 def text_field(name, **attrs) format_self_close_tag(:input, type: "text", name: name.to_s, **attrs) end |