Justin Williams
2007-Jul-16 17:58 UTC
Overriding placeholder text value in custom FormBuilder
Greetings, I have a custom FormBuilder class I''ve created that inputs a placeholder text value on a text_field. It works great unless a user has errors in the form. In that case, the user''s previously submitted values are overridden by my FormBuilder''s placeholder value. How can I override the placeholder value with the user''s submitted values when rendering an InvalidRecord error? My code is here for reference: http://pastie.caboo.se/79203 Thanks for the help. - j --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Justin Williams
2007-Jul-19 00:08 UTC
Re: Overriding placeholder text value in custom FormBuilder
anyone? On Jul 16, 12:58 pm, Justin Williams <carpea...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Greetings, > > I have a custom FormBuilder class I''ve created that inputs a > placeholder text value on a text_field. It works great unless a user > has errors in the form. In that case, the user''s previously submitted > values are overridden by my FormBuilder''s placeholder value. > > How can I override the placeholder value with the user''s submitted > values when rendering an InvalidRecord error? > > My code is here for reference:http://pastie.caboo.se/79203 > > Thanks for the help. > > - j--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 7/17/07, Justin Williams <carpeaqua-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Greetings, > > I have a custom FormBuilder class I''ve created that inputs a > placeholder text value on a text_field. It works great unless a user > has errors in the form. In that case, the user''s previously submitted > values are overridden by my FormBuilder''s placeholder value. > > How can I override the placeholder value with the user''s submitted > values when rendering an InvalidRecord error? > > My code is here for reference: http://pastie.caboo.se/79203 > > Thanks for the help.Hi Justin, Isn''t it enough to only set the content if the field is blank? i.e., wrap your javascript calls to placeholder() in "if (this.value == '''') { ... }" (or make placeholder itself check the condition), and set the :value option to the placeholder text only if the value is blank? The value can be obtained with `object.send(method)'' in your form builder method. I must admit as a user, though, I''m not usually a fan of "placeholder text." Hope this helps, George. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---