1. Mikhail Korobov
  2. django-widget-tweaks
Issue #12 resolved

Variable attribute value

Anonymous created an issue

It would be nice to make possible passing variable attribute values. Like:

{{ field|attr:"placeholder:placeholder_name" }}

Is that possible to do ?

Comments (2)

  1. Mikhail Korobov repo owner

    Yes, I think you can already use variables like this:

    {{ field|attr:my_variable }}  
    

    my_variable should contain "placeholder:placeholder_name" string in this case. Have you tried this? Does it work?

    You may also want to check the last example for render_field in README:

    <!-- template variables can be used as attribute values -->
    {% render_field form.text placeholder=form.text.label %}
    
  2. Log in to comment