Skip to content

Commit

Permalink
Merge pull request #240 from Nobatek/dev_docs_update
Browse files Browse the repository at this point in the history
Docs: add note about field_args
  • Loading branch information
lafrech authored Jun 30, 2016
2 parents 5143083 + f1efb0a commit bdc96c7
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ In the template::
MongoEngine and WTForms
=======================

You can use MongoEngine and WTForms like so::
flask-mongoengine automatically generates WTForms from MongoEngine models::

from flask_mongoengine.wtf import model_form

Expand Down Expand Up @@ -155,9 +155,28 @@ You can use MongoEngine and WTForms like so::
redirect('done')
return render_template('add_post.html', form=form)

For each MongoEngine field, the most appropriate WTForm field is used.
Parameters allow the user to provide hints if the conversion is not implicit::

PostForm = model_form(Post, field_args={'title': {'textarea': True}})

Supported parameters:

For fields with `choices`:

- `multiple` to use a SelectMultipleField
- `radio` to use a RadioField

For `StringField`:

- `password` to use a PasswordField
- `textarea` to use a TextAreaField

(By default, a StringField is converted into a TextAreaField if and only if it has no max_length.)


Supported fields
================
----------------

* StringField
* BinaryField
Expand All @@ -175,7 +194,7 @@ Supported fields
* DictField

Not currently supported field types:
====================================
------------------------------------

* ObjectIdField
* GeoLocationField
Expand Down Expand Up @@ -229,7 +248,7 @@ Upgrading


Credits
========
=======

Inspired by two repos:

Expand Down

0 comments on commit bdc96c7

Please sign in to comment.