#6319 Use html5 required attribute on ticket title field, elsewhere

v1.0.0
closed
sf-1 (616)
General
2015-08-20
2013-05-31
No

The ticket title field is often missed (e.g. [#6275] or [#6298] or other examples), but using the html5 required attribute would catch that problem right away. Easy widgets could make all input fields that have validator with not_empty=True emit the required attribute.

Related

Tickets: #6275
Tickets: #6298

Discussion

  • Dave Brondsema

    Dave Brondsema - 2013-05-31

    Hg is annoying. Here's a patch. I can commit and make a release, but I don't want to figure out forking & branching in hg right now :P

    diff -r ef59dd395c4e ew/fields.py
    --- a/ew/fields.py  Tue Jan 15 21:16:17 2013 +0000
    +++ b/ew/fields.py  Fri May 31 21:26:52 2013 +0000
    @@ -62,6 +62,9 @@
             super(InputField, self).__init__(**kw)
             if self.label is None and self.name:
                 self.label = self.name.capitalize()
    +        if self.validator and getattr(self.validator, 'not_empty', False) == True:
    +            if self.attrs and 'required' not in self.attrs:
    +                self.attrs['required'] = True
    
         def _get_if_missing(self):
             if self._if_missing == ():
    diff -r ef59dd395c4e ew/jinja2_ew.py
    --- a/ew/jinja2_ew.py   Tue Jan 15 21:16:17 2013 +0000
    +++ b/ew/jinja2_ew.py   Fri May 31 21:26:52 2013 +0000
    @@ -20,7 +20,10 @@
             'nohref',
             'ismap',
             'declare',
    -        'defer'])
    +        'defer',
    +        'required',
    +        'autofocus',
    +])
    
     def _escape(s):
         try:
    
     
  • Dave Brondsema

    Dave Brondsema - 2013-05-31
    • status: in-progress --> code-review
     
    • QA: Tim Van Steenburgh
     
  • Dave Brondsema

    Dave Brondsema - 2013-06-03

    I've pushed the changes to https://bitbucket.org/rick446/easywidgets/ on the required_attr branch

     
    • status: code-review --> closed
     

Log in to post a comment.