Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#15924 closed New feature (invalid)

html5 forms input types, attributes

Reported by: roman2k9@… Owned by: nobody
Component: Forms Version: 1.3
Severity: Normal Keywords: forms, html5
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Could you add new html5 features in django forms widgets?
Such as 'email', 'tel', 'url', 'number', and other input types. For Example i solved this problem by writing my own widget like this:

class EmailInput(Input):
    """
    The email input widget
    """
    input_type = 'email'

class ContactUsForm(forms.Form):
    sender = forms.EmailField(
        label='',
        widget=EmailInput(attrs={
            'required': '',
            'placeholder': _('Your email'),
            'title': _('Example: my_mail@gmail.com')}),
        required=True)

This generates HTML:

<form action="contact_us/" id="contact_us_form" method="POST">
    <input name="sender" title="Example: my_mail@gmail.com" type="email" required="" placeholder="Your email" id="id_sender"><label for="id_sender"></label>
</form>

note that new input attributes such as "reqired" must be render automatically by widget (when i write required=True in Field parameters) whithout instead widget attribute 'requred':'' (see above)

HTML5 form attributes:
http://www.w3schools.com/html5/html5_form_attributes.asp

HTML5 input types:
http://www.w3schools.com/html5/html5_form_input_types.asp

Change History (3)

comment:1 by Jonas H., 13 years ago

placeholder would definitely be a very useful addition.

comment:2 by Luke Plant, 13 years ago

Resolution: invalid
Status: newclosed

This ticket is too broad, and it won't be possible to ever consider it fixed.

Please open separate tickets for any feature you'd like to see. I can see a number of tickets here:

  • 'required' attribute
  • placeholder attribute
  • EmailInput widget
  • UrlInput widget etc.

Please note that we have a strong backwards compatibility commitment, so we won't add new features (or at least have them enabled by default) if they break things for older browsers. This is another reason to split this ticket into multiple tickets, so the problems with one won't hold up the others being added.

Can I also note that at least some of these are simple, easy new features (feel free to add the 'Easy pickings' flag to you new tickets), and such things are especially good candidates for you to implement. Core developers are going to spend their time doing things that other members of the community can't do, so nice patches with docs and tests will certainly be welcomed, but we are unlikely to write them :-)

comment:3 by Aymeric Augustin, 13 years ago

UI/UX: unset

Related tickets: #12446 and #16630.

Note: See TracTickets for help on using tickets.
Back to Top