Skip to content

Commit

Permalink
Update doc, final bump to 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sveetch committed Apr 2, 2015
1 parent 82368a4 commit 774f7ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion crispy_forms_foundation/__init__.py
Expand Up @@ -2,4 +2,4 @@
"""
Django application to add 'django-crispy-forms' layout objects for Foundation
"""
__version__ = '0.5.0pre'
__version__ = '0.5.0'
35 changes: 20 additions & 15 deletions docs/usage.rst
Expand Up @@ -12,13 +12,14 @@ Import **crispy-forms-foundation** then you can use the layout objects in your f

.. sourcecode:: python

from crispy_forms_foundation.layout import Layout, Fieldset, Field, SplitDateTimeField, Row, RowFluid, Column, Div, ButtonHolder, Submit, HTML
from crispy_forms_foundation.layout import Layout, Fieldset, SplitDateTimeField, Row, Column, ButtonHolder, Submit

class YourForm(forms.ModelForm):
"""
*Page* form
"""
def __init__(self, *args, **kwargs):
# Init layout form with crispy
self.helper = FormHelper()
self.helper.form_action = '.'
self.helper.layout = Layout(
Expand Down Expand Up @@ -53,33 +54,37 @@ Import **crispy-forms-foundation** then you can use the layout objects in your f
The embedded templates are in ``crispy_forms_foundation/templates/foundation-5``.

Use Foundation 5 Abide
**********************
Use Foundation Abide validation
*******************************

You can use `Abide`_ validation in your form but note that there is no support within the layout objects. You will have to add the ``required`` attribute (and eventually its pattern) on your field widgets in your form.
You can use `Abide`_ validation in your form but note that there is no support within the layout objects. You will have to add the ``required`` attribute (and eventually its validation pattern) on your field widgets in your form like this:

So to enable `Abide`_ you'll have to load its Javascript library if you don't load yet the whole Foundation library, then in your form helper you will have to its attribute on the form like this :
.. sourcecode:: python

title = forms.CharField(label=_('Title'), widget=forms.TextInput(attrs={'required':''}), required=True)

To enable `Abide`_ on your form, you'll have to load its Javascript library (if you don't load yet the whole Foundation library) then in your form helper you will have to add its attribute on the form like this :

.. sourcecode:: python

class SampleForm(forms.Form):
title = forms.CharField(label=_('Title'), widget=forms.TextInput(attrs={'required':''}), required=True)
textarea_input = forms.CharField(label=_('Textarea'), widget=forms.Textarea(attrs={'required':''}), required=True)

def __init__(self, *args, **kwargs):
self.helper = FormHelper()
# Enable Abide validation on the form
self.helper.attrs = {'data_abide': ''}

self.helper.form_action = '.'
self.helper.layout = Layout(
...
)

super(SampleForm, self).__init__(*args, **kwargs)
Then add the required attribute on a field widget like this :

.. sourcecode:: python

textarea_input = forms.CharField(label=_('Textarea'), widget=forms.Textarea(attrs={'required':''}), required=True)

You can also set an abide error message directly on the field like this :
You can also set an `Abide`_ error message directly on the field like this :

.. sourcecode:: python

Expand All @@ -91,7 +96,7 @@ You can also set an abide error message directly on the field like this :
Support within tabs
-------------------

Default **Abide** behavior is not aware of Tabs and so input errors can be hided when they are not in the active tab.
Default `Abide`_ behavior is not aware of Tabs and so input errors can be hided when they are not in the active tab.

**crispy-forms-foundation** ships a jQuery plugin that add support for this usage, you will need to load it in your pages then initialize it on your form:

Expand All @@ -111,7 +116,7 @@ This way, all input errors will be raised to their tab name that will display an
Support within accordions
-------------------------

Like with tabs, there is a jQuery plugin to add Abide support within accordions.
Like with tabs, there is a jQuery plugin to add `Abide`_ support within accordions.

You will need to load it in your pages then initialize it on your form:

Expand All @@ -129,7 +134,7 @@ You will need to load it in your pages then initialize it on your form:
Automatic form layout
*********************

There is some forms you can use to quickly and automatically create a Foundation layout for your forms. This is mostly for fast integration or prototyping because it will probably never fit to your design.
There is some forms you can use to quickly and automatically create a Foundation layout for your forms. This is mostly for fast integration or prototyping because it will probably never totally fit to your design.

.. automodule:: crispy_forms_foundation.forms
:members:

0 comments on commit 774f7ab

Please sign in to comment.