Sha256: e553b4c7a1708e721d22b9c3fdc88036611fc5f8b70ec864c49482f75e538884

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

module Stepper
  module ActionViewAdditions
    module InstanceMethods
      # Render partial from app/views/stepper/_fields
      # Adds buttons "Next", "Previous", "Save" and "Finish" to form and adds hidden field with current step name.
      #
      # Add to locales for changing step names:
      #   en:
      #     stepper:
      #       next_step: 'Next step'
      #       previous_step: 'Previous step'
      #       save: 'Finish later'
      #       finish: 'Finish'
      #
      # +next_step+ button validates, saves current step and renders next step of form;
      # +previous_step+ saves current step and renders previous step of form;
      # +save+ save current step and redirects to index page;
      # +finish+ is showed only for last step instead of +next_step+ button and it validates, saves last step and redirects to show.
      #
      # If you want to have other partial for buttons than add partial to: +app/views/stepper/_fields.html.erb+
      def stepper(form)
        resource = self.instance_variable_get :@_stepper_resource_instance
        current_step_column = resource.stepper_current_step_column
        self.render(:partial => "stepper/fields",
                    :locals => { :f => form,
                                 :resource => resource,
                                 :current_step_column => current_step_column }).to_s
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stepper-0.2.0 lib/stepper/helper/action_view_additions.rb
stepper-0.1.0 lib/stepper/helper/action_view_additions.rb