cliss21
/
django-fsforms
Archivé
5
0
Bifurcation 1
A reusable Django application for rendering forms with Foundation for Sites.
Ce dépôt a été archivé le 2019-09-23. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
 
 
 
Aller au fichier
Jérôme Lebleu 7236efe4b0 doc(README): add a depreciation notice 2019-09-23 10:29:58 +02:00
fsforms build: release v6.0.0 2019-09-23 10:24:15 +02:00
tests [test] Remove useless installed applications 2018-04-11 13:37:09 +02:00
.coveragerc [enh] Improve coverage's Makefile rule and report 2018-02-18 14:05:42 +01:00
.editorconfig [init] Add code, templates and doc with basic features and tests 2017-08-07 16:15:27 +02:00
.gitignore [ref] Build .rst files from Makefile and remove get_version 2018-02-18 14:04:46 +01:00
AUTHORS.md [doc] Switch to markdown for the README and other files 2017-08-15 18:09:44 +02:00
CHANGELOG.md build: release v6.0.0 2019-09-23 10:24:15 +02:00
LICENSE [init] Add code, templates and doc with basic features and tests 2017-08-07 16:15:27 +02:00
MANIFEST.in [ref] Build .rst files from Makefile and remove get_version 2018-02-18 14:04:46 +01:00
Makefile [enh] Improve coverage's Makefile rule and report 2018-02-18 14:05:42 +01:00
README.md doc(README): add a depreciation notice 2019-09-23 10:29:58 +02:00
manage.py [init] Add code, templates and doc with basic features and tests 2017-08-07 16:15:27 +02:00
requirements_test.txt [init] Add code, templates and doc with basic features and tests 2017-08-07 16:15:27 +02:00
runtests.py [ref] Simplify runtests.py and add python3.6 in tox 2018-02-18 12:27:37 +01:00
setup.cfg [ref] Build .rst files from Makefile and remove get_version 2018-02-18 14:04:46 +01:00
setup.py [ref] Build .rst files from Makefile and remove get_version 2018-02-18 14:04:46 +01:00
tox.ini test: update tested environments and versions 2019-09-23 10:21:02 +02:00

README.md

Foundation Forms for Django

Warning! This application is no longer maintained. As a nice and more powerfull alternative, you can switch to django-tapeforms.

A reusable Django application for rendering forms with Foundation for Sites.

Requirements

  • Python 3.5, 3.6 and 3.7
  • Django 2.0.x, 2.1.x and 2.2.x (Jinja2 is not supported yet)
  • 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

  1. Install Foundation Forms for Django:

    pip install django-fsforms
    
  2. Add it to the INSTALLED_APPS in your settings.py:

    INSTALLED_APPS = (
        ...
        'fsforms',
        ...
    )
    
  3. Set the FORM_RENDERER in your settings.py to use fsforms' one:

    • If you are using Django templates:

      FORM_RENDERER = 'fsforms.renderers.DjangoTemplates'
      
    • If you are using TemplateSetting as form renderer, you just have to ensure that the fsforms templates will be sourced before the built-in widgets templates directory.

    Note that this step is required since Django is loading templates first from the built-in form templates directory in django/forms when using those backends (see the Built-in-template form renderers' doc).

Usage

In your template, you will just have to load fsforms then use the fsfield tag to render a form field.

{% load fsforms %}

<form action="/url/to/submit/" method="post">
  {% csrf_token %}
  <ul class="no-bullet">
    <li>{% fsfield form.simple_field %}</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.