Im creating my own form validators, and im submitting the form to itself. My validators work, but the hell, when the form gets reloaded all the contents are lost and if that would happen in real im not sure he/she would bother retyping all the stuff in. How do I get the form data loaded again (without using params or session) Petr -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Oct 5, 1:23 pm, Petr <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Im creating my own form validators, and im submitting the form to > itself. My validators work, but the hell, when the form gets reloaded > all the contents are lost and if that would happen in real im not sure > he/she would bother retyping all the stuff in. How do I get the form > data loaded again (without using params or session)It sounds like you''re using the form_tag helpers (e.g. text_field_tag) rather than the form helpers (e.g. text_field). The form helpers hook into ActiveRecord objects and help you do this kind of redisplay easily, but with the form_tag helpers you need to specify the values manually. For instance, if I have a text field like this: text_field_tag("name") then it will always render as empty when you reload the page, because I''m not telling it what value to display. However, if my controller picks up the data like this: @name = params[:name] then I can change the text field tag to this: text_field_tag("name", @name) and it will use the contents of @name as the default value of the text field when the page is loaded. Chris --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Is it possible to redirect form contents? ie. user submits a form to itself, then it redirects to a different action and display the contents of the form there, without using sessions? Petr Chris Mear wrote:> On Oct 5, 1:23 pm, Petr <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> Im creating my own form validators, and im submitting the form to >> itself. My validators work, but the hell, when the form gets reloaded >> all the contents are lost and if that would happen in real im not sure >> he/she would bother retyping all the stuff in. How do I get the form >> data loaded again (without using params or session) > > It sounds like you''re using the form_tag helpers (e.g. text_field_tag) > rather than the form helpers (e.g. text_field). The form helpers hook > into ActiveRecord objects and help you do this kind of redisplay > easily, but with the form_tag helpers you need to specify the values > manually. > > For instance, if I have a text field like this: > > text_field_tag("name") > > then it will always render as empty when you reload the page, because > I''m not telling it what value to display. > > However, if my controller picks up the data like this: > > @name = params[:name] > > then I can change the text field tag to this: > > text_field_tag("name", @name) > > and it will use the contents of @name as the default value of the text > field when the page is loaded. > > Chris-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---