Sha256: f4926e0bef47b5a9f9ab65193f4d87e16bdce390cf86135737fdb958387c9ea6

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

class FormController < ApplicationController

  include MxitRails::Page

  def index
    form do
      step :start do
        proceed 'Start the form'
      end

      step :name do
        input :name, 'What is your name?'
        validate :not_blank, 'You must enter a name'
        validate 'That is not a cool enough name' do |input|
          input != 'Steve'
        end
      end

      step :surname do
        input :surname, 'What is your surname?'
      end

      step :age do
        input :age, 'What is your age?'

        validate :numeric, 'Please enter numeric digits only'
        validate :max_length, 2, 'Your age cannot be more than 99'
      end

      step :done do
        proceed 'Submit my information'

        @name = params[:name]
        @surname = params[:surname]
        @age = params[:age]
      end

      submit do
        logger.info "Form Completed!\nname: #{params[:name]};  surname: #{params[:surname]};  age: #{params[:age]}\n******\n\n"
        redirect! '/mxit/index/success'
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mxit-rails-0.1.4 test/dummy/app/controllers/form_controller.rb
mxit-rails-0.1.2 test/dummy/app/controllers/form_controller.rb
mxit-rails-0.1.1 test/dummy/app/controllers/form_controller.rb
mxit-rails-0.1.0 test/dummy/app/controllers/form_controller.rb
mxit-rails-0.0.9 test/dummy/app/controllers/form_controller.rb