Sha256: 6100258e2bf98bb77dd15bea37ccf5acafa697053504e9042db09a1d22a2d149

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dorsale-1.2.6 app/helpers/dorsale/form_helper.rb
dorsale-1.2.5 app/helpers/dorsale/form_helper.rb
dorsale-1.2.4 app/helpers/dorsale/form_helper.rb
dorsale-1.2.3 app/helpers/dorsale/form_helper.rb
dorsale-1.2.2 app/helpers/dorsale/form_helper.rb
dorsale-1.2.1 app/helpers/dorsale/form_helper.rb
dorsale-1.2.0 app/helpers/dorsale/form_helper.rb