Roundup Tracker - Issues

Issue 2550961

Title: required attribute incorrectly shown when using field()
Type: behavior Severity: normal
Components: Web interface Versions: devel
Status: new Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: rouilj
Priority: normal Keywords:

Created on 2018-06-24 23:45 by rouilj, last changed 2018-06-24 23:45 by rouilj.

msg6094 Author: [hidden] (rouilj) Date: 2018-06-24 23:45
def cgi_escape_attrs(**attrs):
    return ' '.join(['%s="%s"'%(k,cgi.escape(str(v), True))
        for k,v in attrs.items()])


   <span tal:condition="python:not InBatchUpdate"

in an html template generates:

    <input name="title" required="true" value="test" type="text"
id="title" size="30">

which is incorrect. If it's in html 4/5 required takes no value, so it
should be required not required="true". For xhtml it should be

What should probably happen for all attributes passed through the field
and other functions is:

  if the value is a string, generate attribute="string"
  if the value is True (i.e. the boolean) generate attribute
    for html and attribute="attribute" for xhtml

The functions in cgi/ that need changing are:

def cgi_escape_attrs(**attrs):
    return ' '.join(['%s="%s"'%(k,cgi.escape(str(v), True))
        for k,v in attrs.items()])

def input_html4(**attrs):
    """Generate an 'input' (html4) element with given attributes"""
    return '<input %s>'%cgi_escape_attrs(**attrs)

def input_xhtml(**attrs):
    """Generate an 'input' (xhtml) element with given attributes"""
    return '<input %s/>'%cgi_escape_attrs(**attrs)

probably push the xhtml/html state down into cgi_escape_attrs and
check to see if the value is exactly True.

Do we need to handle False similarly to allow a user to:

                       attrs, required=False )

to delete required if set in attrs? I suppose not as the user could
delete manually if "required" in attrs...
Date User Action Args
2018-06-24 23:45:50rouiljcreate