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 Subject : just a params[:subject] (i.e field not tied either to the 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dhruva Sagar
2009-Dec-23 10:16 UTC
Re: persisting input values not tied to an object in form
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. On Wed, Dec 23, 2009 at 3:41 PM, nisha <nisha0609-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > Subject : just a params[:subject] (i.e field not tied either to the > 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 > > -- > > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Gr8!! Thanks a bunch. it solved my problem :) how cudn''t i think of this simple solution... On Dec 23, 3:16 pm, Dhruva Sagar <dhruva.sa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > On Wed, Dec 23, 2009 at 3:41 PM, nisha <nisha0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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 > > Subject : just a params[:subject] (i.e field not tied either to the > > 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 > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dhruva Sagar
2009-Dec-24 07:59 UTC
Re: Re: persisting input values not tied to an object in form
Happens sometimes, glad it helped :) Thanks & Regards, Dhruva Sagar. On Thu, Dec 24, 2009 at 12:41 PM, nisha <nisha0609-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Gr8!! Thanks a bunch. it solved my problem :) how cudn''t i think of > this simple solution... > > > > On Dec 23, 3:16 pm, Dhruva Sagar <dhruva.sa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 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. > > > > On Wed, Dec 23, 2009 at 3:41 PM, nisha <nisha0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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 > > > Subject : just a params[:subject] (i.e field not tied either to the > > > 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 > > > > > -- > > > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.