A reusable Django application for rendering forms with Foundation for Sites.
Project description
A reusable Django application for rendering forms with Foundation for Sites.
Requirements
Python 3
Django >= 1.11
Foundation for Sites 6.x
Note that this application does not include Foundation for Sites assets so that you can customize it as you need. Get started by reading its documentation!
Features
Displays the field label as well as its help text
Renders the Django base Widgets following the Forms component’s guidelines
Shows the field errors as needed and sets the proper CSS classes on the field label and the input
Installation
Install Foundation Forms for Django:
pip install django-fsforms
Add it to the INSTALLED_APPS in your settings.py:
INSTALLED_APPS = ( ... 'fsforms', ... )
Change the FORM_RENDERER still in your settings.py to use the Foundation Forms’ one:
FORM_RENDERER = 'fsforms.renderers.FoundationTemplates'
Usage
In your template, you will just have to load fsforms then use either the fsfield filter on a field for a basic usage, or the fsfield tag for tunning up the output.
{% load fsforms %}
<form action="/url/to/submit/" method="post">
{% csrf_token %}
<ul class="no-bullet">
<li>{{ form.simple_field|fsfield }}</li>
<li>{% fsfield form.other_field label_class="my-field" %}</li>
</ul>
<div class="button-holder">
<button type="submit" class="button">Submit</button>
</div>
</form>
Here are the special arguments you can pass to the fsfield tag: - show_label: a boolean which turns on or off the label output. Note that label of choices widgets will always be displayed. - label_class: a string which contains additional CSS classes to apply to the label element. - show_errors: a boolean which turns on or off the field errors’ output as well as the CSS classes applied to the elements - e.g. is-invalid-input and is-invalid-label. Default is True. - as_list: a boolean which controls the rendering of choices widgets - i.e. RadioSelect and CheckboxSelectMultiple. When set to True - the default, the fields will be rendered inline and wrapped inside a fieldset as suggested by the Forms component. Otherwise, they will be rendered as a list.
All the remaining arguments will be added to the widget attributes. As regards the required one, you can alter its value too but only with client-side effect. It means that if a field is defined as required in the form class and you pass required=False to the tag, it will appear as non-required to the user but will still be validated at the form’s submission.
License
You can use this under GNU AGPLv3+. See LICENSE file for details.
Changelog
Unreleased
6.0.0b3 - 2017-09-16
Added
Basic fsfield tag and filter for Foundation for Sites 6.x.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_fsforms-6.0.0b3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31fc62deed3b2d45f9e11b56237ed7a72a9d79ed9aaa8aed2ca7c4fa05a9fb7f |
|
MD5 | f5d2f57d228909846ac495cba67b24fe |
|
BLAKE2b-256 | 6f9743fcebd4428bd257ce45f5784c57634f008803ac11c087b92c4395676b0c |