python-2.7web2py-modules

How to use helpers for list objects


I have this code:

my_table = db.define_table('my_table',
    Field('mt_table_id', 'id', requires=[IS_NOT_EMPTY()]),

I need to add something like requires= IS_LIST() to get a list e.g. ['a','b','c'] instead of ['a,b,c']. How is that done?


Solution

  • I ain't got what you meant, but perhaps you should look at custom validators section in web2py's book: http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#Custom-validators

    You may create a custom validator called IS_LIST() and change the "formatter" method to return a list in the way that you want.