Module: Para::FormBuilder::Containers
- Defined in:
- lib/para/form_builder/containers.rb
Instance Method Summary collapse
- #actions(options = {}, &block) ⇒ Object
- #actions_buttons_for(options) ⇒ Object
- #component_path ⇒ Object
- #fieldset(options = {}, &block) ⇒ Object
- #para_cancel_button ⇒ Object
- #para_submit_and_add_another_button ⇒ Object
- #para_submit_and_edit_button ⇒ Object
- #para_submit_button(options = {}) ⇒ Object
- #return_to_hidden_field ⇒ Object
- #return_to_path ⇒ Object
Instance Method Details
#actions(options = {}, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/para/form_builder/containers.rb', line 18 def actions( = {}, &block) template.content_tag(:div, class: 'block form-actions form-group') do template.content_tag(:div, class: 'col-sm-9 col-sm-offset-3') do if block template.capture(&block) else if .empty? [:only] = template.instance_variable_get(:@component).default_form_actions end ().join("\n").html_safe end end end end |
#actions_buttons_for(options) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/para/form_builder/containers.rb', line 33 def () names = [:submit, :submit_and_edit, :submit_and_add_another, :cancel] names.select! { |name| Array.wrap([:only]).include?(name) } if [:only] names.reject! { |name| Array.wrap([:except]).include?(name) } if [:except] = names.map { |name| send(:"para_#{ name }_button") } .unshift(return_to_hidden_field) end |
#component_path ⇒ Object
71 72 73 74 75 |
# File 'lib/para/form_builder/containers.rb', line 71 def component_path if (component = template.instance_variable_get(:@component)) component.path end end |
#fieldset(options = {}, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/para/form_builder/containers.rb', line 4 def fieldset( = {}, &block) template.content_tag(:div, class: 'block form-inputs') do buffer = if (title = [:title]) template.content_tag(:div, class: 'form-group') do template.content_tag(:legend, title) end else ''.html_safe end buffer + template.capture(&block) end end |
#para_cancel_button ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/para/form_builder/containers.rb', line 59 def template.link_to( ::I18n.t('para.shared.cancel'), return_to_path, class: 'btn btn-danger' ) end |
#para_submit_and_add_another_button ⇒ Object
55 56 57 |
# File 'lib/para/form_builder/containers.rb', line 55 def (:submit, ::I18n.t('para.shared.save_and_add_another_button'), name: '_save_and_add_another', class: 'btn-primary') end |
#para_submit_and_edit_button ⇒ Object
51 52 53 |
# File 'lib/para/form_builder/containers.rb', line 51 def (:submit, ::I18n.t('para.shared.save_and_edit'), name: '_save_and_edit', class: 'btn-primary') end |
#para_submit_button(options = {}) ⇒ Object
47 48 49 |
# File 'lib/para/form_builder/containers.rb', line 47 def ( = {}) (:submit, ::I18n.t('para.shared.save'), name: '_save', class: 'btn-success') end |
#return_to_hidden_field ⇒ Object
43 44 45 |
# File 'lib/para/form_builder/containers.rb', line 43 def return_to_hidden_field template.hidden_field_tag(:return_to, return_to_path) end |
#return_to_path ⇒ Object
67 68 69 |
# File 'lib/para/form_builder/containers.rb', line 67 def return_to_path template.params[:return_to].presence || component_path end |