Skip to content

Commit bdc96c7

Browse files
authored
Merge pull request #240 from Nobatek/dev_docs_update
Docs: add note about field_args
2 parents 5143083 + f1efb0a commit bdc96c7

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

docs/index.rst

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ In the template::
127127
MongoEngine and WTForms
128128
=======================
129129

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

132132
from flask_mongoengine.wtf import model_form
133133

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

158+
For each MongoEngine field, the most appropriate WTForm field is used.
159+
Parameters allow the user to provide hints if the conversion is not implicit::
160+
161+
PostForm = model_form(Post, field_args={'title': {'textarea': True}})
162+
163+
Supported parameters:
164+
165+
For fields with `choices`:
166+
167+
- `multiple` to use a SelectMultipleField
168+
- `radio` to use a RadioField
169+
170+
For `StringField`:
171+
172+
- `password` to use a PasswordField
173+
- `textarea` to use a TextAreaField
174+
175+
(By default, a StringField is converted into a TextAreaField if and only if it has no max_length.)
176+
158177

159178
Supported fields
160-
================
179+
----------------
161180

162181
* StringField
163182
* BinaryField
@@ -175,7 +194,7 @@ Supported fields
175194
* DictField
176195

177196
Not currently supported field types:
178-
====================================
197+
------------------------------------
179198

180199
* ObjectIdField
181200
* GeoLocationField
@@ -229,7 +248,7 @@ Upgrading
229248

230249

231250
Credits
232-
========
251+
=======
233252

234253
Inspired by two repos:
235254

0 commit comments

Comments
 (0)