|Version 3 (modified by 13 years ago) ( diff ),|
This one has all properties of IS_ONE_OF but one:
it does not send back to the browser a potentially huge dropdown with all values.
Instead, it creates the INPUT box which can carry the corresponding lookup id.
And when the form gets sent back to the server, the content of this INPUT box gets validated on the server against the corresponding lookup table.
How to use the IS_ONE_OF_EMPTY?
Keep in mind that the corresponding model assumes default validator against the organisation_id.
The working example is controllers/or.py:
here the organisation_id is not mandatory, but: if present, must be validated against the (large) organisation table.
def office(): ... # the update forms are not ready. when they will - uncomment this and comment the next one #if request.args(0) in ('create','update'): if request.args(0) == 'create': db[table].organisation_id.requires = IS_NULL_OR(IS_ONE_OF_EMPTY(db, 'or_organisation.id')) ...
Note: the method update has a separate view file, and as of now it is not having the auto-complete functionality yet.
Once it is ready, the line
if request.args(0) in ('create','update'):
will replace the existing one, taking care of just create:
if request.args(0) == 'create':
2. View - Auto-complete
And the complimentary view or/office_create.html