Re: set the css class of a form widget based on the data

2014-11-14 Thread Michael Palumbo
Thanks Russell, that works well. On Thu, Nov 13, 2014 at 11:30 PM, Russell Keith-Magee < russ...@keith-magee.com> wrote: > Hi Michael, > > The best bet would be to write a custom widget, and override the render() > method. render() takes the name of the widget, the value to render, and a >

Re: set the css class of a form widget based on the data

2014-11-13 Thread Russell Keith-Magee
Hi Michael, The best bet would be to write a custom widget, and override the render() method. render() takes the name of the widget, the value to render, and a dictionary of attr values. In your subclass, you can override this method to inject the additional attributes based on the provided value

set the css class of a form widget based on the data

2014-11-12 Thread Michael
Hi, The ``attrs`` attribute of a widget allows to define the html attributes. For example, setting it to ``widget.attrs['class'] = 'class1 class2'`` will add ``class="class1 class2"`` on the rendered widget. However, how can I set them based on the data? I display an update form and I'd like