@Massimo,

Thanks for your reply.
I gave the code a try I had to remove name= from the Field definition, now 
I am stuck at form=SQLFORM.factory(*fields_list)
it gives me the following error:

Traceback (most recent call last):
  File "/Users/annet/web2py/gluon/restricted.py", line 212, in restricted
    exec ccode in environment
  File "/Users/annet/web2py/applications/init/controllers/cmssite.py" 
<http://127.0.0.1:8000/admin/edit/init/controllers/cmssite.py>, line 536, in 
<module>
  File "/Users/annet/web2py/gluon/globals.py", line 188, in <lambda>
    self._caller = lambda f: f()
  File "/Users/annet/web2py/gluon/tools.py", line 2912, in f
    return action(*a, **b)
  File "/Users/annet/web2py/applications/init/controllers/cmssite.py" 
<http://127.0.0.1:8000/admin/edit/init/controllers/cmssite.py>, line 97, in 
site_functions
    form=SQLFORM.factory(*fields_list)
  File "/Users/annet/web2py/gluon/sqlhtml.py", line 1534, in factory
    return SQLFORM(DAL(None).define_table(table_name, *fields),
  File "/Users/annet/web2py/gluon/dal.py", line 7086, in define_table
    table = self.lazy_define_table(tablename,*fields,**args)
  File "/Users/annet/web2py/gluon/dal.py", line 7103, in lazy_define_table
    table = table_class(self, tablename, *fields, **args)
  File "/Users/annet/web2py/gluon/dal.py", line 7512, in __init__
    self[field_name] = field
  File "/Users/annet/web2py/gluon/dal.py", line 7680, in __setitem__
    .update(**self._filter_fields(value)) is None:
  File "/Users/annet/web2py/gluon/dal.py", line 7606, in _filter_fields
    return dict([(k, v) for (k, v) in record.iteritems() if k
AttributeError: 'Field' object has no attribute 'iteritems'


I have a similar function in which I use SQLFORM.factory() with a fixed 
Field set:

form=SQLFORM.factory(
    Field('phone',length=128,requires=IS_LENGTH(128)),
    Field('fax',length=128,requires=IS_LENGTH(128)),
    Field('cell_phone',length=128,requires=IS_LENGTH(128)),
    Field('email',length=128,requires=requirement,label=label),
    
Field('URL',length=128,requires=IS_EMPTY_OR(IS_URL(prepend_scheme=None))),
    separator='')

In the function I am working on now I'd like to use SQLFORM.factory() with 
a variable Field set
hence the fields_list solution. Why doesn't this work?


@Alan,
Thanks for your reply, I am using Allan Jardines datatables, however, for 
reasons of consistency I prefer
a form based solution. Furthermore, I no longer import crud, so I am 
looking for a none crud solution.


Kind regards,

Annet

-- 



Reply via email to