Hi, 

I try to develop layer over SQLFORM
which would fully preserve field info (even better than in book example 
<http://web2py.com/books/default/chapter/29/07/forms-and-validators#One-form-for-multiple-tables>
)

Ii call it AnySQLFORM 
https://github.com/dz0/web2py_grand_helpers/blob/master/app/controllers/plugin_AnySQLFORM.py

I want it to return Row object:
in my "test" example: 

the fields/expressions are:
        db.auth_user.first_name, 
        db.auth_user.last_name, 
        
        db.auth_user.id,
        
        db.auth_permission.table_name,
        db.auth_permission.id,
        
        Field( 'somefield' ),
        Field('user_id', 'reference auth_user', 
requires=IS_IN_DB(db,db.auth_user.id, '%(first_name)s %(last_name)s')),
        FormField(db.auth_user.first_name + db.auth_user.last_name, 
name='full_name'),


if *form.vars *are
<Storage {'auth_user__last_name': 'Dow', 'auth_user__first_name': 'John', 
'no_table__somefield': 'asdf', 
'auth_permission__table_name': 'bla', 
'auth_user__id': 4, 
'full_name': 'ohn', 
'no_table__user_id': 4, 
'auth_permission__id': 3}>




the *self.**vars_as_Row()* takes request.vars and returns

<Row {'auth_user': {'first_name': 'John', 'last_name': 'Dow', 'id': '4'}, 
           'auth_permission': {'table_name': 'bla', 'id': '3'}, 
           'no_table': {'user_id': '2', 'somefield': 'asdf'}, 
            '_extra': {'(auth_user.first_name || auth_user.last_name)': 
'ohn'}}>

I want to use it primarily as search from, so it can have even Expresssion 
instead of Field.

***
I implemented FormField as extension of Field, 
and AnySQLFORM as proxy to form_factory result... 

not sure if I do it nicely -- so review/advice is welcome :) 
 

-- 
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.

Reply via email to