I have a sort of solution (but don't like it). I subclassed the crispy-
tag to change the input's into span's/uneditable's. This is done using
re's which is the part i don't like, it will only work as long as the
raw html is compatible with the re's....

I know a better solution is to create custom templates for the field
for example but i'm missing complete and working examples to do that;
anyone advise?

Paul



class CrispyUneditable(UniFormNode):
    '''subclass the crispy tag to modify the tags output: each input
field shall be uneditable using bootstraps uneditable styling'''
    def render(self, context):
        import re
        value = super(CrispyUneditable, self).render(context)
        return  re.sub(
            r'<input (.*?) value="([^"]*?)" class="([^"]*)" (.*?)>',
            r'<span class="\3 uneditable-input">\2</span>', value)

# {% crispy-uneditable %} tag
@register.tag(name="crispy-uneditable")
def do_crispy_uneditable_form(parser, token):
    token = token.split_contents()
    form = token.pop(1)

    try:
        helper = token.pop(1)
    except IndexError:
        helper = None

    return CrispyUneditable(form, helper)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to