Skip to content

Commit

Permalink
more docs improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Jun 2, 2024
1 parent 573c60e commit c0f6b72
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 207 deletions.
1 change: 1 addition & 0 deletions apps/_default/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ <h1>x = [[=x]]</h1>
<li>Automatic generation of <a href="https://py4web.com/_documentation/static/en/chapter-08.html">RESTful APIs</a> for your database.</li>
<li>Built-in logic for <a href="https://py4web.com/_documentation/static/en/chapter-13.html#user-impersonation">user impersonation</a>.</li>
<li>Integrated <a href="https://github.com/web2py/py4web/blob/master/apps/_scaffold/settings.py#L75">SSO support</a> for Google, Github, Facebook, Okta, LDAP, PAM</li>
<li>A built-in <a href="https://py4web.com/_documentation/static/en/chapter-16.html">scheduler</a> for submitting and managing async background tasks.</li>
</ul>
</div>

Expand Down
Binary file modified apps/_documentation/static/en/_images/form1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
166 changes: 76 additions & 90 deletions apps/_documentation/static/en/chapter-12.html

Large diffs are not rendered by default.

Binary file modified apps/_documentation/static/en/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/_documentation/static/en/searchindex.js

Large diffs are not rendered by default.

Binary file modified apps/_documentation/static/pt/_images/form1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
166 changes: 76 additions & 90 deletions apps/_documentation/static/pt/chapter-12.html

Large diffs are not rendered by default.

Binary file modified apps/_documentation/static/pt/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/_documentation/static/pt/searchindex.js

Large diffs are not rendered by default.

55 changes: 30 additions & 25 deletions docs/chapter-12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ an app derived from the scaffolding app:

.. code:: python
db.define_table(
'thing',
Field('name', requires=IS_NOT_EMPTY()),
Field('color', requires=IS_IN_SET(['red','blue','green'])),
Field('image', 'upload', download_url=lambda name: URL('download', name)),
)
db.define_table(
'thing',
Field('name', requires=IS_NOT_EMPTY()),
Field('color', requires=IS_IN_SET(['red','blue','green'])),
Field('image', 'upload', download_url=lambda name: URL('download', name)),
)
The Form constructor
Expand All @@ -76,22 +76,22 @@ The ``Form`` constructor accepts the following arguments:

.. code:: python
Form(self,
table,
record=None,
readonly=False,
deletable=True,
formstyle=FormStyleDefault,
dbio=True,
keep_values=False,
form_name=False,
hidden=None,
validation=None,
csrf_session=None,
csrf_protection=True,
lifespan=None,
signing_info=None,
):
Form(self,
table,
record=None,
readonly=False,
deletable=True,
formstyle=FormStyleDefault,
dbio=True,
keep_values=False,
form_name=False,
hidden=None,
validation=None,
csrf_session=None,
csrf_protection=True,
lifespan=None,
signing_info=None,
):
Where:

Expand Down Expand Up @@ -224,7 +224,7 @@ Reload py4web and visit http://127.0.0.1:8000/create_form :
the result is an input form on the top of the page, and the list of all the
previously added entries on the bottom:

.. image:: images/form2.png ### FIX THIS
.. image:: images/form2.png

This is a simple example and you cannot change nor delete existing records. But if you'd
like to experiment, the database content can be fully seen and changed with the Dashboard app.
Expand Down Expand Up @@ -430,6 +430,7 @@ For example you could use it to avoid displaying the ``id`` field while editing

.. code:: html

[[extend 'layout.html']]
[[=form.custom.begin ]]
[[for field in DETAIL_FIELDS: ]]
[[ if field not in ['id']: ]]
Expand Down Expand Up @@ -457,11 +458,15 @@ Note: 'custom' is just a convention, it could be any name that does not clash wi

You can also be more creative and use your HTML in the template instead of using widgets:

[[=form.custom.begin ]]
.. code:: html

[[extend 'layout.html']]

[[for field, error form.errors.items:]]
<div class="error">Field [[=field]] [[=error]]</div>
[[pass]]

[[=form.custom.begin ]]

<div class="select">
<input name="name" value="form.vars.get('name', '')"/>
Expand All @@ -470,7 +475,7 @@ You can also be more creative and use your HTML in the template instead of using
[[for color in ['red', 'blue', 'green']:]]
<label>[[=color]]</label>
<input name="color" type="radio" value="[[=color]]"
[[if form.vars.get('color') == color]]checked[[pass]]
[[if form.vars.get('color') == color:]]checked[[pass]]
/>
[[pass]]
</div>
Expand Down

0 comments on commit c0f6b72

Please sign in to comment.