Tom Nijam
Tom Nijam

Reputation: 1

Ruby, how do I split a simple_form with multiple fields across multiple screens so it's 1 field per screen

Could not find the answer for how to split a simple_form across multiple screens so that it's one form per screen, then you confirm.

I have a big form with:

I'd like this to be split across four screens so it's less overwhelming for the user, and it just looks nicer. What would be the best way to do that?

Thanks so much!

Upvotes: -1

Views: 165

Answers (1)

Inba
Inba

Reputation: 71

I have worked on a similar requirement and this seems to work for us.

in controller..

def new
  ...
end

def create
  record.step = 1
  # create record
  ...
  render step_2
end

def step_2
  ...
end

# POST /controller/:id/update_step_2
def update_step_2
  record.step = 2
  # update object
  ...
end

step is a attr_acessor in model. This will be used in validation conditions.

Upvotes: 0

Related Questions