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.

HTML5 form field helpers (email_field_tag, etc.)

#3646

As HTML5 becomes more popular, it would be nice to have convenience methods for the new input types.

This patch includes and tests the following:

  • email_field_tag (and email_field)
  • url_field_tag (etc.)
  • telephone_field_tag (aliased to phone_field_tag)
  • number_field_tag
  • range_field_tag
  • search_field_tag

All of the above function on (Mobile) Safari and Opera, and all will gracefully degrade across other browsers.

Reported by Stephen Celis · January 3rd, 2010 @ 07:05 PM

State: committed
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: none

Activity

  1. Tony Pitale
  2. Ryan Bigg
    Ryan Bigg

    +1

    I think it's best to have this in now (3.0) than later.

    January 5th, 2010 @ 03:53 AM

  3. Stephen Celis
    Stephen Celis

    Additional patch that merely fixes the "text_field type: override" bug.

    Discussion here: http://groups.google.com/group/rubyonrails-core/browse_thread/threa...

    I still think that we should prefer adding the helpers, as well, to encourage their use.

    January 5th, 2010 @ 02:34 PM

  4. Dan Croak
    Dan Croak

    +1 the accept-alternate-text-field-types.diff patch.

    January 5th, 2010 @ 05:13 PM

  5. Alex Kahn
    Alex Kahn

    +1 This is beautiful.

    January 6th, 2010 @ 04:05 PM

  6. Maxim Filatov
  7. Kevin McFadden
  8. Bruce Williams
    Bruce Williams

    +1 the accept-alternate-text-field-types.diff patch.

    January 8th, 2010 @ 08:16 PM

  9. Repository
  10. José Valim
    José Valim
    • State changed from new to resolved
    • Assigned user set to José Valim

    January 14th, 2010 @ 01:08 AM

  11. Jeremy Kemper
    Jeremy Kemper
    • Milestone cleared.
    • State changed from resolved to open

    Let's get the full helpers in. Could you rebase against master?

    April 5th, 2010 @ 11:57 PM

  12. Jeremy Kemper
    Jeremy Kemper

    Interested in seeing autofocus and placeholder support with javascript fallback, too, if anyone wants to tackle in another ticket.

    April 6th, 2010 @ 12:02 AM

  13. Repository
    Repository
    • State changed from open to committed

    (from [f8730e5ce6bba4de7639ac09c6c193458038f748]) Added all the new HTML5 form types as individual form tag methods (search, url, number, etc) (Closes #3646 HTML5 form field helpers (email_field_tag, etc.)) [Stephen Celis] http://github.com/rails/rails/commit/f8730e5ce6bba4de7639ac09c6c193...

    April 6th, 2010 @ 12:08 AM

  14. Jeremy Kemper
  15. michaelxavier
    michaelxavier

    Hate to necro but is there any possible way to get this backported to 2.X? It is surprisingly painful to retrofit existing forms with HTML5 input types.

    April 9th, 2011 @ 04:33 AM

  16. Justin French
    Justin French

    @michaelxavier is it really that painful? text_field(:user, :email_address, :type => :email) has worked pretty well for me.

    April 9th, 2011 @ 06:22 AM