django-widget-tweaks icon indicating copy to clipboard operation
django-widget-tweaks copied to clipboard

Optionally add attributes

Open ironfroggy opened this issue 10 years ago • 2 comments

Some attributes trigger behaviors and meanings simply by their presence, such as the readonly attribute. In these cases even an empty string passed to render_field will cause the field to have the readonly attribute and be read-only, so there is no way to do this and pass 'false' in any form.

In the way that render_field supports both = and += to set or append an attribute, a syntax to optionally add would be great. OR, explicit support for fields like readonly that would just ignore the attribute if the value given was false.

ironfroggy avatar Jan 28 '15 12:01 ironfroggy

I like the idea. Something like {% render_field form.text readonly?=value %}? Pull requests are welcome.

kmike avatar Jan 28 '15 13:01 kmike

The pull request from @Kos looks pretty good! Any chance this will be merged soon?

svengt avatar Jun 27 '16 12:06 svengt