Class: C::CFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- C::CFormBuilder
- Defined in:
- app/helpers/c/c_form_builder.rb
Instance Method Summary collapse
- #error_messages ⇒ Object
- #image_field(method, options = {}) ⇒ Object
- #price_field(method, _options = {}) ⇒ Object
- #tiny_mce_text_area(method, tinymce_config = 'standard') ⇒ Object
Instance Method Details
#error_messages ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'app/helpers/c/c_form_builder.rb', line 4 def return unless object.respond_to?(:errors) && object.errors.any? header = @template.content_tag(:h4, 'Errors prevented the form from saving', class: 'title-error') errors_array = object.errors..map { || @template.content_tag(:li, ) } errors_list = @template.safe_join([header, @template.safe_join(errors_array)]) @template.content_tag(:ul, @template.raw(errors_list), class: 'form_errors') end |
#image_field(method, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/helpers/c/c_form_builder.rb', line 28 def image_field(method, = {}) @template.field_set_tag '', class: 'image_field' do @template.content_tag(:span, method.to_s.titleize, class: 'fieldset-title') + hidden_field("#{method}_cache") + (@template.image_tag(@object.send(method)) || '') + file_field(method, ) end end |
#price_field(method, _options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/c/c_form_builder.rb', line 14 def price_field(method, ={}) @template.field_set_tag '', class: 'price_field' do @template.content_tag(:span, method.to_s.titleize.to_s, class: 'fieldset-title') + fields_for(method) do |builder| @template.content_tag(:div, class: 'gs') do @template.content_tag(:div, class: 'field field--inner-label g-1') { builder.label(:without_tax) + builder.number_field(:without_tax, step: 0.01, min: 0) } + @template.content_tag(:div, class: 'field field--inner-label g-1 g-gutter--narrow') { builder.label(:with_tax) + builder.number_field(:with_tax, step: 0.01, min: 0) } + @template.content_tag(:div, class: 'field field--inner-label g-1 g-gutter--narrow') { builder.label(:tax_rate) + builder.number_field(:tax_rate, step: 0.01, min: 0) } end + builder.label(:override) { builder.check_box(:override) + @template.content_tag(:span, 'Override tax rate', class: 'checkbox-span-label') } end end end |
#tiny_mce_text_area(method, tinymce_config = 'standard') ⇒ Object
37 38 39 40 |
# File 'app/helpers/c/c_form_builder.rb', line 37 def tiny_mce_text_area(method, tinymce_config='standard') text_area(method, class: 'tinymce') + @template.send("tinymce_#{tinymce_config}") end |