# Overriding placeholder text value in custom FormBuilder

**URL:** <https://www.ruby-forum.com/t/overriding-placeholder-text-value-in-custom-formbuilder/109553>\
**Category:** Rails\
**Created:** [July 16, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/overriding-placeholder-text-value-in-custom-formbuilder/109553 "2007-07-16T19:59:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [July 16, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/overriding-placeholder-text-value-in-custom-formbuilder/109553/1 "2007-07-16T19:59:49Z")

</div>

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: [Parked at Loopia](http://pastie.caboo.se/79203)

Thanks for the help.

- j

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [July 19, 2007, 2:09am UTC](https://www.ruby-forum.com/t/overriding-placeholder-text-value-in-custom-formbuilder/109553/2 "2007-07-19T02:09:59Z")

</div>

anyone?

---

<div class="post-metadata">

**Author:** ![rubylover](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8c91f0/32.png) [@rubylover](https://www.ruby-forum.com/u/rubylover)\
**Post date:** [July 19, 2007, 5:10am UTC](https://www.ruby-forum.com/t/overriding-placeholder-text-value-in-custom-formbuilder/109553/3 "2007-07-19T05:10:20Z")

</div>

On 7/17/07, Justin W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My code is here for reference: [Parked at Loopia](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.
