Sha256: cf5a032d233ed06aeacb7f7190ad414ea1b30a7b9cccff3b6cd682c3e735c266

Contents?: true

Size: 1.73 KB

Versions: 18

Compression:

Stored size: 1.73 KB

Contents

module Optimacms
  module SimpleFormExtensions
    module ButtonComponents
      def submit_cancel(*args, &block)
        template.content_tag :div, :class => "form-group" do
        template.content_tag :div, :class => "col-sm-offset-1 col-sm-6" do
          options = args.extract_options!

          # class
          options[:class] = [options[:class], 'btn', 'btn-primary', 'btn-lg'].compact

          #
          args << options


          # with cancel link
          if cancel = options.delete(:cancel)
            submit(*args, &block) + '&nbsp;&nbsp;'.html_safe + template.link_to(I18n.t('simple_form.buttons.cancel'), cancel)
          else
            submit(*args, &block)
          end

        end
        end
      end

      def save_continue_cancel(*args, &block)
        template.content_tag :div, :class => "form-group" do
          template.content_tag :div, :class => "col-sm-offset-1 col-sm-6" do
            options = args.extract_options!

            # class
            options[:class] = [options[:class], 'btn', 'btn-primary', 'btn-lg'].compact

            #
            args << options

            buttons = submit(*args, &block) + '&nbsp;&nbsp;'.html_safe+
                template.link_to(I18n.t('simple_form.buttons.save_continue'), '#', {class: options[:class]+['btn-save-continue']})

            # with cancel link
            if cancel = options.delete(:cancel)
              (buttons+'&nbsp;&nbsp;'.html_safe + template.link_to(I18n.t('simple_form.buttons.cancel'), cancel)).html_safe
            else
              buttons.html_safe
            end

          end
        end
      end

    end

    SimpleForm::FormBuilder.send :include, ButtonComponents
  end
end


Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
optimacms-0.3.35 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.3.34 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.3.30 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.3.29 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.3.23 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.3.15 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.3.12 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.3.11 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.2.26 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.2.25 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.2.24 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.3.4 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.3.3 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.2.21 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.2.20 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.2.16 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.2.15 lib/optimacms/simple_form_extensions/button_components.rb
optimacms-0.2.14 lib/optimacms/simple_form_extensions/button_components.rb