Module: Optimacms::SimpleFormExtensions::ButtonComponents

Defined in:
lib/optimacms/simple_form_extensions/button_components.rb

Instance Method Summary collapse

Instance Method Details

#save_continue_cancel(*args, &block) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/optimacms/simple_form_extensions/button_components.rb', line 27

def save_continue_cancel(*args, &block)
  template. :div, :class => "form-group" do
    template. :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

#submit_cancel(*args, &block) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/optimacms/simple_form_extensions/button_components.rb', line 4

def submit_cancel(*args, &block)
  template. :div, :class => "form-group" do
  template. :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