hi,
is it possible to adapt sqlform.factory into form? i've tried before but 
the result is not expected
e.g.
*controllers/default.py*
account = db(db.account.id > 0).iterselect()

list_show = [('chart', T('Chart') ), 
('product', T('Product') ) ]

*# not work no error occured, but the result is not expected, result just 
show : "None"*
def form_field_show(list_show):
for value, label in list_show:
DIV(INPUT(_type = 'checkbox', _value = value, _name = 'show') )
LABEL(label)

*# want to show zero parameter like in IS_IN_DB parameter*
form_field_account = lambda account: \
DIV(SELECT(_name = 'account', 
*[OPTION('%s' % (acc.name), _value = str(acc.id) ) for acc in account] ) )

requires_account = lambda : \
IS_IN_DB(db, db.account.id, db.account._format, zero = T('Choose One') )

requires_set_not_empty = lambda list_value: IS_IN_SET(list_value, zero = 
current.T('Choose One') )

requires_set_multiple_empty = lambda list_value: IS_IN_SET(list_value, 
multiple = True)

requires_set_multiple_not_empty = lambda list_value: \
[IS_IN_SET(list_value, multiple = True), 
IS_NOT_EMPTY() ]

def form():
"""
form = SQLFORM.factory(
Field("account", "reference account", 
 requires = requires_account() ),
Field('show', 'list:string', 
 requires = requires_set_multiple_empty(list_show_account),
 widget = SQLFORM.widgets.checkboxes.widget), 
)
"""
form = FORM( 
form_field_show(list_show),
)
if form.process(formname = 'form_detail').accepted:
...
elif form.errors:
...
return dict(form = form)

in code above is work with sqlform.factory, i want to move it into form, 
there some questions about that
1. the checkbox with list of tuples is not shown, the result is just shown 
"None", how to make it work using web2py FORM() ?
2. the checkbox have 2 condition one, that can empty and another can not 
empty, how to make it work using web2py FORM() ?
3. in IS_IN_DB() and IS_IN_SET() there are parameter zero, how to show zero 
parameter in web2py FORM() for case like that?
4. in SQLFORM support comment, is it possible to have it too in web2py 
FORM()?
5. it seems, not all form validation requires is work with FORM() already 
test with IS_IN_DB(), any thoughts?

thanks and best regards,
stifan

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to