=============== Rendering Forms =============== .. versionadded:: 0.6 .. currentmodule:: djem.templatetags.djem Djem provides some simple template tags to assist in rendering form fields in templates. While Django provides numerous ways to customise the way it renders form fields, they are often inadequate. The options for `rendering all of a form's fields `_ as a series of ````, ``
  • ``, or ``

    `` tags, are limited to providing fairly basic field/label pairs, with little opportunity for customisation. And `rendering fields manually `_ often results in repeating boilerplate code, e.g. specifying a wrapping element, the field, its label, its error list, etc. The :ttag:`form_field` and :ttag:`checkbox` template tags use a fully customisable template to render each individual field. The template, found at ``djem/form_field.html``, can be altered per-project using Django's standard `template overriding mechanism `_. By default, it provides: * A wrapping element with the following features: * By default, the element is a ``

    ``, but this can be modified using the :setting:`DJEM_FORM_FIELD_TAG` setting. * The element is given the following CSS classes: * ``form-field`` * Any classes defined by the form. See below examples. * Any classes passed to the template tag. See below examples. * The element is given additional HTML attributes based on keyword arguments passed to the template tag. See below examples. * The field's label (for fields rendered with ``form_field``, see below examples). * The field's error list (when applicable). The error list is the Django default ``
      ``. * The field itself. * The specified checkbox label (for fields rendered with ``checkbox``, see below examples). This ``