Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add ignore_date option to date helpers so Rails doesn't hidden field tags

#503

Date helpers render hidden input tags so valid dates are created in a form, this is great, but...

Example case: I am using for the same attribute a time_select and a date_select in the same form for design reasons.

form.time_select(:starts_at) will render hidden field tags for day, month and year, so the params are a valid date when parsing them, but in this case i don't want them to be hidden i want to put them somewhere else.

With this patch you could do something like:


<%= form.date_select(:starts_at) %>

<%= form.time_select(:starts_at, :ignore_date => true) %>

Reported by Emilio Tagua · July 1st, 2008 @ 03:16 PM

State: resolved
Milestone: none
Assigned to: Emilio Tagua Emilio Tagua
Importance: none

Activity

  1. Emilio Tagua
    Emilio Tagua
    • Title changed from Add ignore_date option to date helpers so Rails doesn't hidden field tags to Add ignore_date option to date helpers so Rails doesn't render hidden field tags
    • Tag set to actionpack, patch

    July 1st, 2008 @ 03:28 PM

  2. Repository
    Repository
    • State changed from new to resolved

    (from [570f5aad663fa3113772cf56306862829babc739]) Allow date helpers to ignore date hidden field tags. [#503 state:resolved]

    Signed-off-by: Pratik Naik

    http://github.com/rails/rails/co...

    July 4th, 2008 @ 02:13 AM

  3. Jeremy Kemper
  4. Aditya Sanghi
    Aditya Sanghi
    • Title changed from Add ignore_date option to date helpers so Rails doesn't render hidden field tags to Add ignore_date option to date helpers so Rails doesn't hidden field tags
    • Assigned user set to Emilio Tagua
    • Tag cleared.

    Sorry to open up a topic more than 2 years old but it's caused (https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets....

    Just wondering the use case stated here could not have been handled by datetime_select?

    Using time_select with :ignore_date => true causes an errors if the date_select on the same field has not been provided. Moreover, if you enter the time as 01 hours, 02 minutes and 03 seconds, Rails wouldn't even know that its a problem and consider it Year 1, Month 2, Day 3 and NO error would be popped.

    Also the documentation does not state anywhere that if you do indeed use :ignore_date => true, you MUST also remember to use date_select on the same field. After much digging, this is the only place this requirement is stated.

    I would be of the opinion to revert this functionality, please do share your thoughts.

    October 9th, 2010 @ 09:51 AM