Issue 2550961
Created on 2018-06-24 23:45 by rouilj, last changed 2024-07-17 04:14 by rouilj.
Messages | |||
---|---|---|---|
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()]) Using: <span tal:condition="python:not InBatchUpdate" tal:content="structure python:context.title.field(id='title', required="true")">title</span> 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 required="required". 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/templating.py 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""" _set_input_default_args(attrs) return '<input %s>'%cgi_escape_attrs(**attrs) def input_xhtml(**attrs): """Generate an 'input' (xhtml) element with given attributes""" _set_input_default_args(attrs) 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: tal:content="structure python:context.title.field(id='title', attrs, required=False ) to delete required if set in attrs? I suppose not as the user could delete manually if "required" in attrs... |
|||
msg8111 | Author: [hidden] (rouilj) | Date: 2024-07-17 04:14 | |
Using: <span tal:condition="python:not InBatchUpdate" tal:content="structure python:context.title.field(id='title', required=None)">title</span> does generate: <input name="title" required value="test" type="text" id="title" size="30"> This is now documented at https://rouilj.dynamic- dns.net/~rouilj/roundup_docs/docs/reference.html#hyperdb-property-wrapper |
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-07-17 04:14:34 | rouilj | set | status: new -> fixed assignee: rouilj resolution: fixed messages: + msg8111 |
2018-06-24 23:45:50 | rouilj | create |