Improvements to render_form.
This commit is contained in:
parent
7f6cbf66fb
commit
25589a79d3
3 changed files with 316 additions and 91 deletions
|
|
@ -14,18 +14,24 @@ def init_entry_routes(app):
|
|||
cls = crudkit.crud.get_model(model)
|
||||
if cls is None:
|
||||
abort(404)
|
||||
obj = crudkit.crud.get_service(cls).get(id, {"fields": ["first_name", "last_name", "title", "supervisor"]})
|
||||
obj = crudkit.crud.get_service(cls).get(id, {"fields": ["first_name", "last_name", "title", "active", "staff", "location", "location_id"]})
|
||||
if obj is None:
|
||||
abort(404)
|
||||
|
||||
fields_spec = [
|
||||
{"name": "last_name", "label": "Last Name", "attrs": {"placeholder": "Doe"}},
|
||||
{"name": "first_name", "label": "First Name", "attrs": {"placeholder": "John"}},
|
||||
{"name": "title", "label": "Title", "attrs": {"placeholder": "President of the Universe"}},
|
||||
{"name": "active", "label": "Active"},
|
||||
{"name": "staff", "label": "Staff Member"},
|
||||
{"name": "location", "label": "Room", "label_spec": "{name} - {room_function.description}"}
|
||||
]
|
||||
form = render_form(
|
||||
cls,
|
||||
obj.as_dict(),
|
||||
crudkit.crud.get_service(cls).session,
|
||||
label_specs={
|
||||
"supervisor": "{first_name} {last_name}",
|
||||
"location": "{name} - {room_function.description}"
|
||||
},
|
||||
instance=obj,
|
||||
fields_spec=fields_spec
|
||||
)
|
||||
|
||||
return render_template("entry.html", form=form)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue