Way to set class containing widget name ?

Issue #10 new
Anonymous created an issue

I wanted to be able to set a css class with the widget name in it, so TextInput would become text... I used the following code

def input_type(field):
    Given a value with type xxxInput returns xxx

    So CheckboxInput returns checkbox

    :return: name converted for use in css

    type_name = field.__class__.__name__.lower().split('input')[0]
    return type_name

def add_widget_type_class(field):
    Add a css class with the fields widget type
    widget_type = input_type(field.field.widget)
    return wt_tags.add_class(field, widget_type)

Still - I reckon this isn't deal - having a way to pass these into the functions would be useful.

Comments (2)

  1. Log in to comment