Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7084983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:22:08+00:00 2026-05-28T07:22:08+00:00

Could not find the answer to the question on how to split forms in

  • 0

Could not find the answer to the question on how to split forms in rails in multiple smaller forms.

Say you have a big form with

  • firstname
  • lastname
  • gender
  • age
  • email
  • country
  • city
  • state

I have a validate_presence for all these fields. So when I create several forms like:

= simple_form_for @profile, :wrapper => :inline do |f|

  = f.label "firstname"
  = f.select :firstname

without all the values from the top list (first name,last name,etc) I get errors because the splitter form does not contain those values and they need to be present at first to make this work at all.

What would be a good way to have several forms but with only a portion of the values and update them without getting the issue described above?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:22:09+00:00Added an answer on May 28, 2026 at 7:22 am

    If you want the ability to update pieces of the model then you need to split the validations into pieces as well.

    One way to do it is to have a virtual attribute in your model that gets set by a hidden field in each form. E.g you may have a form:

    = simple_form_for @profile, :wrapper => :inline do |f|
      = f.hidden :form, :input_html => {:value => 'names'} 
      = f.label "firstname"
      = f.select :firstname
    

    Then in your model:

    class Profile
      attr_accessor :form
    
      validates :firstname, :presence => true, :if => lambda { |o| o.form == "names" }
    end
    

    The validation will run only if the change was submitted from the right form.

    Check out conditional validation guide: http://guides.rubyonrails.org/active_record_validations_callbacks.html#conditional-validation for more details.

    Other way is a multistep form as suggested by apneadiving: http://railscasts.com/episodes/217-multistep-forms This uses the same technique as in the first example by having a current_step attribute, but the progression is linear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I could not find a clear answer to this question elsewhere, so I'll try
I have been searching everywhere but I could not find an answer. I need
I have been looking for an answer to this and could not find it
This is a very basic MySQL question but I could not find an answer.
This might look like a beaten question, but could not find an answer at
I have search all over the web but could not find answer to this
I looked through old threads but could not find the answer to my question:
I looked all over for the answer to my question and could not find
I have searched google but could not find an answer to what I think
This question sounds too trivial, but I could not find the answer anywhere. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.