Forum: Ruby on Rails Overriding placeholder text value in custom FormBuilder

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Justin W. (Guest)
on 2007-07-16 21:59
(Received via mailing list)

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:

Thanks for the help.

- j
Justin W. (Guest)
on 2007-07-19 04:09
(Received via mailing list)
George (Guest)
on 2007-07-19 07:10
(Received via mailing list)
On 7/17/07, Justin W. <removed_email_address@domain.invalid> wrote:
> My code is here for reference:
> 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

I must admit as a user, though, I'm not usually a fan of "placeholder

Hope this helps,
This topic is locked and can not be replied to.