Allow the use of HTML in form field help texts

Also make the help text show under the field itself for regular fields,
and in the left column only for textarea fields. This makes it possible
to use longer help texts without making things look really bad...
This commit is contained in:
Magnus Hagander
2012-01-20 13:45:40 +01:00
parent 4911b0fff8
commit d3a0bd94dd
2 changed files with 14 additions and 2 deletions

View File

@ -7,3 +7,7 @@ register = template.Library()
def hidemail(value):
return value.replace('@', ' at ')
@register.filter(name='class_name')
def class_name(ob):
return ob.__class__.__name__

View File

@ -1,4 +1,5 @@
{%extends "base/page.html"%}
{%load pgfilters%}
{%block title%}{{operation|default:"Edit"}} {{formitemtype}}{%endblock%}
{%block contents%}
<h1>{{operation|default:"Edit"}} {{formitemtype}}</h1>
@ -22,10 +23,17 @@
</tr>
{%endif%}
<tr {%if field.errors%}class="errorinfo"{%endif%}>
<th>{{field.label_tag}}{%if field.help_text %}<br/>
<span class="formfieldhelp">{{field.help_text}}</span>{%endif%}</th>
<th>{{field.label_tag}}{%if field.help_text%}{%if field.field.widget|class_name == "Textarea"%}<br/>
<span class="formfieldhelp">{{field.help_text|safe}}</span>{%endif%}{%endif%}
</th>
<td>{{field}}</td>
</tr>
{%if field.help_text %}{%if field.field.widget|class_name != "Textarea"%}
<tr>
<th></th>
<td><span class="formfieldhelp">{{field.help_text|safe}}</span></td>
</tr>
{%endif%}{%endif%}
{%endfor%}
</table>
<input type="submit" value="{{savebutton|default:"Save"}}" />