sadeesh kumar
2008-Jul-04 04:58 UTC
need default value for my input element when there is no desired param
Hi, In my form I set a default value as "enter text" for my text box. In case of validation failure i am rendering the form, where i loss the user entered text (instead the default value is appearing in the text box). So, i need to set the default value only when there is no particular param. How could i get this? Any one Please... Thanks, -Sadeesh kumar. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Thorsten Müller
2008-Jul-04 07:23 UTC
Re: need default value for my input element when there is no desired param
Depends on how you handle the data. params[:field] ||= "default" will set params[:field] to "default" if it''s nil, leave it as is, if it has a value --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
sadeesh kumar
2008-Jul-04 07:37 UTC
Re: need default value for my input element when there is no desired param
Hi Thorsten, Now I got it. Thanks, -Sadeesh kumar. On Jul 4, 12:23 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> Depends on how you handle the data. > > params[:field] ||= "default" > will set params[:field] to "default" if it''s nil, leave it as is, if > it has a value--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---