#22383 Add the HTML5 required tag to the input fields which are required for database entry

Showing 1-5 of 5 messages
#22383 Add the HTML5 required tag to the input fields which are required for database entry Anubhav Joshi 4/10/14 10:49 AM
A ticket has been opened asking to add HTML5 required tag in forms for the fields which are required for database entry.

There have been several issues:
  1. Is this new option going to stay or is it just transitional.
  2. Is it going to be an optional feature or default behaviour.
  3. Should we be using a proper deprecation strategy or make it default on master as a backward-incompaible change as otherwise it will be of not much use.
  4. The number of users wanting this may be quite a many.

Refs. #22383

People involved in discussion uptil now on ticket on IRC or ticket: timograham, loic84, apollo13  and me.

Re: #22383 Add the HTML5 required tag to the input fields which are required for database entry Anubhav Joshi 4/10/14 11:00 AM


On Thursday, April 10, 2014 11:19:18 PM UTC+5:30, anubhav joshi wrote:
A ticket has been opened asking to add HTML5 required tag in forms for the fields which are required for database entry.

Better wording:
"required for database entry" --> fields have required attribute as True
Re: #22383 Add the HTML5 required tag to the input fields which are required for database entry Gregor Müllegger 4/10/14 4:27 PM
I think adding the `required` attribute but ignoring the other possible html form validations (like `min` and `max` [1] for <input> that are used by the forms.IntegerField) seems a bit half-hearted.

My opinion is that having the required attribute is pretty cool, but should come with all other possible validations baked in then.
django-floppyforms already includes those validations already in the HTML output of forms and it turns out to be quite useful in many situations. Even if you turn of the browser validation by adding the novalidate attribute to the <form> tag, it's good to have this meta data in the HTML representation, e.g. for styling.

Gregor

[1] https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Data_form_validation


--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/f7f8a915-8cc4-4505-8bc3-770599afeb30%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Re: #22383 Add the HTML5 required tag to the input fields which are required for database entry Anubhav Joshi 4/11/14 12:51 AM


On Friday, April 11, 2014 4:57:33 AM UTC+5:30, Gregor Müllegger wrote:
I think adding the `required` attribute but ignoring the other possible html form validations (like `min` and `max` [1] for <input> that are used by the forms.IntegerField) seems a bit half-hearted.

My opinion is that having the required attribute is pretty cool, but should come with all other possible validations baked in then.
django-floppyforms already includes those validations already in the HTML output of forms and it turns out to be quite useful in many situations. Even if you turn of the browser validation by adding the novalidate attribute to the <form> tag, it's good to have this meta data in the HTML representation, e.g. for styling.

Gregor

Thanks Gregor, but I think here we first need to make it clear do we really want it.
Re: #22383 Add the HTML5 required tag to the input fields which are required for database entry Tim Graham 5/19/14 5:00 PM

Here is a more concrete proposal based on Loic's comment in the ticket:

A normal deprecation cycle based on the value of a new `use_required_attribute` boolean attribute on forms.

To deprecate you could do:

class form.Form(object):
    #...
    use_required_attribute = None

class BoundField(object):
    #...
    def as_widget():
	if self.form.use_required_attribute is None:
	    warnings.warn("The required attribute will be turned on by default in Django X.X unless you opt-out.")
	elif form.use_required_attribute:
	    attrs['required'] = True

Now what happens next depends on the actual goal, do we want to use use_required_attribute as a permanent way to control this feature, or as a mere deprecation tool.

Personally I'm (Loic) not thrilled by this feature, although I know lot of people will want it, so I'd like to keep the switch.

Another point of interest, right now there is no way to tell a form that it should render as HTML4 or HTML5. When we discussed #20684 we acknowledged that if someone really cared about HTML4 validation, they could use required="required" instead of required=True, but if this becomes the default and we kill use_required_attribute, we'd be outputting HTML5.