|Version 4 (modified by 11 years ago) ( diff ),|
Popups for Form reference data
When adding items, the opened window should be a popup, Submit should close that window & pre-populate the main form with the result.
Model should include a comment like this:
db.table.field.comment = A(T("Add Contact"), _class="colorbox", _href=URL(c="pr", f="person", args="create", vars=dict(format="popup")), _target="top"))
We use jQuery to catch the click for the class=colorbox (in
There is a special format=popup added to the CRUD controller in
This uses it's own view:
views/popup.html, the intelligence for which is in
Refresh of the calling dropdown is handled via the 'caller' var (which is added automatically).
This works automatically for reusable fields such as 'location_id', however if creating additional fields in your table with alternate names, then also need to pass a 'child' variable (in the vars dict in your .comment) which refers to the fieldname that needs refreshing.