persisting input values not tied to an object in form

Hi all.

I have a form with multiple models and there are certain input fields that are not tied to any model. Now when this form is submitted and when validation error occurs, the form shows up with the fields that are not belonging to any model as blank. i.e it does not persist the input values for those input fields. is there a way to persist input values that are not tied to the model?

To make the scenario clear, let me explain with an eg. Suppose a form contains : Project Id : hidden field for project model User Name : tied to user model (child of project ) User email :tield to user model project or the user models) Division : just a params[:division] (i.e field not tied to either of the models)

Now if i provide the input valus for the above and submit this form and if there is any validation error, the form shows up with subject and division as blank values even thought the values were supplied. So essentially it is not persisting the values between two actions. can anyone suggest how to retain those input values.

Thanks in advance Nisha

Actually the non-model specific fields you have should be available in the params after the model redirects back to the view after some validation errors.

So say the param / name of the param for the non-model field is subject, it’s value will be available with params[:subject] so you can feed this to the field.

Same thing goes for other non-model fields.

Thanks & Regards, Dhruva Sagar.

Gr8!! Thanks a bunch. it solved my problem :slight_smile: how cudn't i think of this simple solution...

Happens sometimes, glad it helped :slight_smile:

Thanks & Regards, Dhruva Sagar.