{% macro form_field(field) -%}
    {% set with_label = kwargs.pop('with_label', False) %}
    {% set placeholder = '' %}
    {% if not with_label %}
        {% set placeholder = field.label.text %}
    {% endif %}
    <div class="form-group {% if field.errors %}error{% endif %}">
        {% if with_label %}
            <label for="{{ field.id }}" class="control-label">
                *{{ field.label.text }}{% if field.flags.required %}{% endif %}:
            </label>
        {% endif %}
        <div class="controls">
            {% set class_ = kwargs.pop('class_', 'form-control') %}
            {% if field.flags.required %}
                {% set required_ = True %}
            {% else %}
                {% set required_ = False %}
            {% endif %}
            {% if field.type == 'BooleanField' %}
                <label class="checkbox">
                    {{ field(class_=class_, **kwargs) }}
                    {{ field.label.text|safe }}
                </label>
            {% elif field.type == 'MultiCheckboxField' %}
                {% set class_ = 'list-inline' %}
                {{ field(class_=class_, style=style_, **kwargs) }}
            {% else %}
                {% if field.type in ('TextField', 'TextAreaField',
                                     'PasswordField') %}
                    {% set class_ = class_ + ' input-xlarge' %}
                {% elif field.type == 'FileField' %}
                    {% set class_ = class_ + ' input-file' %}
                {% endif %}
                {{ field(class_=class_, placeholder=placeholder,
                         required=required_, **kwargs) }}
            {% endif %}
            {% if field.errors %}
                <span class="error help-inline">
                    {{ field.errors|join(', ') }}
                </span>
            {% endif %}
            {% if field.description %}
                <p class="help-block">{{ field.description|safe }}</p>
            {% endif %}
        </div>
    </div>
{%- endmacro %}