Individual field rendering? #49

kokujin opened this Issue Jan 30, 2013 · 3 comments


None yet

2 participants


I would like to add extra markup and other changes to certain fields in my templates. How can I individually render the fields of a form in my template? Thanks

// Something like this
{% for field in formObj.fields %}
{% if field.widget.type === 'email' %}

... do something else
{% endif %}
{% endfor %}


Can you provide an example of what you intend? The entire purpose of widgets is for that to be the mechanism for customizing a field, instead of having to do it in your template.


I have several forms in my application, but just one template to render them all. I would like to make the changes depend on CSS and markup values in the template than to make the changes in all the forms.


I'm not sure I understand. To render a form using this module, you just call .toHTML() on the form object. If you have a special CSS class you want applied to email fields, then you can make your own email widget that calls the default one, and then extends it with your own CSS classes. Then, the form container in the template's CSS markup can use these form field classes to style things however you like.

Can you provide a JSFiddle that illustrates what you're trying to do? Based on my current understanding, your use case doesn't fit what this module does - ie, the form object should contain knowledge of how to both validate it, and entirely render it. What template it's in doesn't and shouldn't matter.

@ljharb ljharb was assigned Feb 18, 2013
@ljharb ljharb closed this Apr 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment