Forum: Ruby on Rails Form fields show 0 instead of blank, how to fix?

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.
Sean S. (Guest)
on 2005-12-13 10:00
I've got a scaffold generated form with a bunch of standard fields like
name, phone number, address, plus some numeric ones like price, branch
number, etc.

When the user first arrives at the form, I'd like the form to be totally
blank.  But right now, those numeric fields are all filled with zero's.

What's the correct way to solve this?  Thanks in advance :)
Bruce B. (Guest)
on 2005-12-13 15:58
(Received via mailing list)

Not too sure what the CORRECT way is but assuming aesthetics is your
concern, here are two possible solutions - one more amusing than the

1.	Convert the number to a string (it will be anyway  once the form
has dealt with it (I believe) and then use an if to say if attribute
whatever = "0" then attribute whatever = ""

2.	Alternatively, if your form has a white background, you could
use :class to have the text start as white and then change to black
using :onfocus

This topic is locked and can not be replied to.