Sha256: a13bd9df87d861b6e613cd2a649e7a3137ef94a1e1294fc7ffb6e64785709520

Contents?: true

Size: 1.19 KB

Versions: 24

Compression:

Stored size: 1.19 KB

Contents

module Dorsale
  module FormHelper
    def form_buttons(opts = {})
     back_url = opts[:back_url]
     back_url = url_for(:back).html_safe if back_url.nil?

      if opts[:obj].present?
        if opts[:obj].new_record?
          submit_action = :create
        else
          submit_action = :update
        end
      else
        submit_action = :save
      end

      content_tag("div", class: "actions cdiv") do
        submit = content_tag(:button, type: :submit, class: "btn btn-sm btn-success") do
          icon(:save) + " " + t("actions.#{submit_action}")
        end

        cancel = content_tag("a", href: back_url, class: "btn btn-primary btn-sm") do
          icon(:times) + " " + t("actions.cancel")
        end

        cancel = "" if back_url == false

        submit + cancel
      end
    end

    def horizontal_form_for(obj, opts={}, &block)
      opts = {
        :wrapper => "horizontal_form",
        :html => {
          :class => "form-horizontal"
        }
      }.deep_merge(opts)

      simple_form_for(obj, opts, &block)
    end

    def search_form(opts = {})
      action = opts.delete(:action) || request.fullpath

      render "dorsale/search/form", action: action
    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
dorsale-2.2.6 app/helpers/dorsale/form_helper.rb
dorsale-2.2.5 app/helpers/dorsale/form_helper.rb
dorsale-2.2.4 app/helpers/dorsale/form_helper.rb
dorsale-2.2.3 app/helpers/dorsale/form_helper.rb
dorsale-2.2.2 app/helpers/dorsale/form_helper.rb
dorsale-2.2.1 app/helpers/dorsale/form_helper.rb
dorsale-2.2.0 app/helpers/dorsale/form_helper.rb
dorsale-2.1.15 app/helpers/dorsale/form_helper.rb
dorsale-2.1.14 app/helpers/dorsale/form_helper.rb
dorsale-2.1.13 app/helpers/dorsale/form_helper.rb
dorsale-2.1.12 app/helpers/dorsale/form_helper.rb
dorsale-2.1.11 app/helpers/dorsale/form_helper.rb
dorsale-2.1.10 app/helpers/dorsale/form_helper.rb
dorsale-2.1.9 app/helpers/dorsale/form_helper.rb
dorsale-2.1.8 app/helpers/dorsale/form_helper.rb
dorsale-2.1.7 app/helpers/dorsale/form_helper.rb
dorsale-2.1.6 app/helpers/dorsale/form_helper.rb
dorsale-2.1.5 app/helpers/dorsale/form_helper.rb
dorsale-2.1.4 app/helpers/dorsale/form_helper.rb
dorsale-2.1.3 app/helpers/dorsale/form_helper.rb