Values in form fields lost after validation

Can you post your controller code? It looks like the @contact_detail object isn't being populated. It's probably something to do with the order that you're assigning and validating things.

Chris

Yu Co wrote:

the relevant code piece of the corresponding controller looks like this:

def create   @contact_detail = ContactDetail.new(params[:contact_detail])   @customer = Customer.new(params[:customer])   @customer.contact_detail = @contact_detail

  if @customer.save      session['user'] = @customer      session[:customer] = nil      else

     begin        session[:errors] = @errors      end end

I can't see how you're redisplaying the form. Are you doing a render(:action => :new)? Are you redirecting back to the 'new' action using redirect_to(:action => :new)? Or do you have a separate create.rhtml template?

Chris

Yu Co wrote:

and the controller auth looks like this:

  def register     @customer = session[:customer] == nil ? Customer.new : session[:customer]     @errors = session[:errors]   end

I checked the values within 'register' action. And indeed the entered data in the form is available under @customer.contact_detail. But after submitting the form the contact_detail dates are not shown but the customer dates.

Your view is expecting to find the contact_detail object in @contact_detail, but you're not setting this in the controller code.

Try adding:

@contact_detail = @customer.contact_detail

to your register action.

Chris