Creating a custom crud.read form and I would like to show the
field.requires=IS_IN_DB field rather than the table.id . Sorry if that
doesn't make much sense. I have two related tables.

db.define_table('employee', Field('firstName'), Field('lastName'),
Field('dept_id'))
db.define_table('department', Field('dept_id'), Field('dept_name'))
db.employee.dept_id.requires=IS_NULL_OR(IS_IN_DB(db,'department.dept_id','department.dept_name'))

I would like to make a custom form to show the employee name and
department.

def employee_form():
  form = crud.read(db.employee, request.args[0])
  return dict(form=form)


## View
{{=form.custom.begin}}
First Name: {{=form.custom.widget.firstName}}
Last Name: {{=form.custom.widget.lastName}}
Department: {{=form.custom.widget.dept_id}}
{{=form.custom.end}}

This returns the actual dept_id for the Department, but I would like
to return the dept_name. Is there a better method to accomplish this
or can some explain custom widgets. I have read the book for custom
widgets but didn't completely understand it.

Reply via email to