Back to Examples Run this application locally to try examples


import os

from py4web import action
from py4web.utils.form import Form, FormStyleDefault

from .common import T, session
from .models import db

# exposed as /examples/create_form or /examples/update_form/<id>
@action("create_form", method=["GET", "POST"])
@action.uses("examples/form.html", db, session, T)
def create_form():
    form = Form(db.person, formstyle=FormStyleDefault)
    rows = db(db.person).select()
    return dict(form=form, rows=rows)


[[extend 'layout.html']]

<h2 class="title">Form Superhero Identity</h2>


<h2 class="title">Rows</h2>

  [[for row in rows:]]
  <li>[[]]: [[]] ([[=row.job]]) <a href="../update_form/[[]]">edit</a></li>
  <li><a href="../create_form">create</a></li>