Hi Anthony,
Thanks for your reply. I changed my code to:
db[table].navID.widget = lambda f, v: SQLFORM.widgets.options.widget(f, v,
_disabled=True)
...
form = SQLFORM(table, record, deletable=deletable, showid=False)
request.post_vars.navID = record.navID
This solves the valiadtion issue, however, it renders the drop down without
the form-control selector:
<select id="nav_vertex_nav_navID" class="generic_widget" name=navID"
disabled=disabled>
whereas it should be rendered :
<select id="nav_vertex_nav_navID" class="generic_widget form-control"
name=navID" disabled=disabled>
This also happens when the form contains an error, I solved this by adding
these lines of code:
elif form.errors:
if form.element('select[name=navID]'):
form.element('select[name=navID]').update(_class='generic-widget
form-control')
I have the following validator on the navID field:
def set_requirement(nav_vertex_nav):
db.nav_vertex_nav.navID.requires=[IS_IN_DB(db, 'nav_nav.id', '%(id)s
%(name)s'),
IS_NOT_IN_DB(db(db.nav_vertex_nav.vertexID==request.vars.vertexID),
'nav_vertex_nav.navID')]
On this field:
Field('navID', 'reference nav_nav', default='', ondelete='CASCADE',
notnull=True, widget=SQLFORM.widgets.options.widget)
Since the field is disabled in the form I could replace it with:
db[table].navID.requires = IS_IN_DB(db, 'nav_nav.id', '%(id)s %(name)s',
something = lambda do something)
don't I? I wasn't able to figure out how to code the lambda ....
Kind regards,
Annet
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.