Module: CMS::FormHelper
- Defined in:
- app/helpers/cms/form_helper.rb
Instance Method Summary collapse
- #cms_form_for(options = {}) ⇒ Object
- #cms_form_options(options = {}) ⇒ Object
- #cms_form_partial ⇒ Object
- #cms_form_send ⇒ Object
- #cms_form_sending(options = {}) ⇒ Object
- #cms_validate_check_boxes(options = {}) ⇒ Object
- #cms_validate_email(options = {}) ⇒ Object
- #cms_validate_presence(options = {}) ⇒ Object
- #cms_validates(options = {}) ⇒ Object
Instance Method Details
#cms_form_for(options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'app/helpers/cms/form_helper.rb', line 3 def cms_form_for( = {}) simple_form_for(cms_form_instance, ()) do |f| concat f.invisible_captcha(:_subtitle) yield f if @cms_view concat f.input(:structure_id, as: :hidden, input_html: { value: cms_form_instance.structure_id }) end end end |
#cms_form_options(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/cms/form_helper.rb', line 13 def ( = {}) if @cms_view url = @cms_view.url else url = main_app.__send__("#{cms_form_instance.form_name}_path") end .reverse_merge! url: url if cms_form_instance. [:multipart] = true else [:remote] = true end end |
#cms_form_partial ⇒ Object
28 29 30 |
# File 'app/helpers/cms/form_helper.rb', line 28 def cms_form_partial "cms/forms/#{params[:cms_view_type]}/form" end |
#cms_form_send ⇒ Object
62 63 64 |
# File 'app/helpers/cms/form_helper.rb', line 62 def cms_form_send t('cms.form.submit.send') end |
#cms_form_sending(options = {}) ⇒ Object
66 67 68 |
# File 'app/helpers/cms/form_helper.rb', line 66 def cms_form_sending( = {}) { 'data-disable-with' => t('cms.form.submit.sending') }.merge() end |
#cms_validate_check_boxes(options = {}) ⇒ Object
58 59 60 |
# File 'app/helpers/cms/form_helper.rb', line 58 def cms_validate_check_boxes( = {}) { 'data-validation' => 'checkbox_group', 'data-validation-qty' => 'min1', 'data-validation-error-msg' => t('errors.messages.blank') }.merge() end |
#cms_validate_email(options = {}) ⇒ Object
54 55 56 |
# File 'app/helpers/cms/form_helper.rb', line 54 def cms_validate_email( = {}) { 'data-validation' => 'email', 'data-validation-error-msg' => t('errors.messages.invalid') }.merge() end |
#cms_validate_presence(options = {}) ⇒ Object
50 51 52 |
# File 'app/helpers/cms/form_helper.rb', line 50 def cms_validate_presence( = {}) { 'data-validation' => 'required', 'data-validation-error-msg' => t('errors.messages.blank') }.merge() end |
#cms_validates(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/helpers/cms/form_helper.rb', line 32 def cms_validates( = {}) type, required = .extract!(*Form::Field::TYPES.map(&:to_sym)).first unless type return cms_validate_presence() end unless required return end case type when :check_boxes cms_validate_check_boxes() when :email cms_validate_email() else cms_validate_presence() end end |