Forum: Ruby on Rails managing dates in forms

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Randy S. (Guest)
on 2006-02-22 19:10
(Received via mailing list)
Hi,

I have a field for the user which is their birthday. I am letting them
edit it and then save it if they want. However, the form displays the
current date/time, and when they save the form without changing the
birthdate (because they do not wish to set it), the current date/time
gets saved to the db. How do I do this? I thought about having a
hidden field which would be the current date/time and after they
submit the form, compare it to the nonhidden value to see if they
changed it, but I feel like that is not a clean way to do it. Any
suggestions? Do I need to clarify more?

Thanks!
--
Randy S.
removed_email_address@domain.invalid
267.334.6833
Anthony G. (Guest)
on 2006-02-22 19:28
Randy S. wrote:
> Hi,
>
> I have a field for the user which is their birthday. I am letting them
> edit it and then save it if they want. However, the form displays the
> current date/time, and when they save the form without changing the
> birthdate (because they do not wish to set it), the current date/time
> gets saved to the db. How do I do this? I thought about having a
> hidden field which would be the current date/time and after they
> submit the form, compare it to the nonhidden value to see if they
> changed it

But what if their birthday is the current date ?

Something simple like a checkbox include my birthday might be best and
validate that its been checked.
This topic is locked and can not be replied to.