Class: ComfortableMexicanSofa::FormBuilder
- Inherits:
-
ComfyBootstrapForm::FormBuilder
- Object
- ComfyBootstrapForm::FormBuilder
- ComfortableMexicanSofa::FormBuilder
- Defined in:
- lib/comfortable_mexican_sofa/form_builder.rb
Instance Method Summary collapse
-
#form_actions ⇒ Object
Wrapper for form action that is sticking to the bottom of the viewport.
-
#fragment_field(tag, index) ⇒ Object
Renders form input for a fragment.
Instance Method Details
#form_actions ⇒ Object
Wrapper for form action that is sticking to the bottom of the viewport. Example:
= form.form_actions do
= form.submit
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/comfortable_mexican_sofa/form_builder.rb', line 35 def form_actions content_tag(:div, class: "form-actions row bg-light") do content_tag(:div, class: "col-lg-8 offset-lg-2") do content_tag(:div, class: "form-group row mb-0") do content_tag(:div, class: "col-sm-10 offset-sm-2") do yield end end end end end |
#fragment_field(tag, index) ⇒ Object
Renders form input for a fragment
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/comfortable_mexican_sofa/form_builder.rb', line 10 def fragment_field(tag, index) tag.form_field(object_name, @template, index) do |tag_input| name = "#{object_name}[fragments_attributes][#{index}][identifier]" identifer_input = @template.hidden_field_tag(name, tag.identifier, id: nil) name = "#{object_name}[fragments_attributes][#{index}][tag]" value = tag.class.to_s.demodulize.underscore tag_name_input = @template.hidden_field_tag(name, value, id: nil) label = I18n.t("comfy.cms.content.tag.#{tag.identifier}", default: tag.identifier.titleize) renderable = tag.respond_to?(:renderable) ? tag.renderable : true form_group bootstrap: { label: { text: label, for: tag.form_field_id, class: "renderable-#{renderable}" } } do concat identifer_input concat tag_name_input concat tag_input end end end |