it's work now, even in the tuple inside the list data type, my bad to treat 
the list data type in an unproper manner, hehe
*is_in_set list checkboxes refer to rows table database *
*e.g.*
def attendance_form():
target_response = "jQuery('#attendance_checkout').get(0).reload()"

rows_list_employee = db(db.employee.id > 0).iterselect()
list_employee = []
for row_list_employee in rows_list_employee:
data_employee = (row_list_employee.id, '%s' % (row_list_employee.name) )
list_employee.append(data_employee)

form = SQLFORM.factory(
Field('employee', 'list:string', 
 widget = SQLFORM.widgets.checkboxes.widget, 
 requires = [IS_IN_SET(list_employee, multiple = True), IS_NOT_EMPTY() ] ), 
)
if form.process(formname = 'form_detail').accepted:
response.flash = T('Form accepted')
for row_id in request.vars.employee:
id = int(row_id)
row_employee = db(db.employee.id == id).iterselect().first()

query_attendance = ((db.attendance.employee == row_employee.id) & 
(db.attendance.attendance_date == request.now) )
row_attendance = db(query_attendance).iterselect().first()

if row_attendance:
response.flash = T("Employee already insert today")
else:
basic_salary = int(row_employee.basic_salary)
meal = int(row_employee.meal)
transport = int(row_employee.transport)

total = basic_salary + meal + transport

session_attendance[id] = basic_salary, meal, transport, total
response.js =  target_response
elif form.errors:
response.flash = T('Form has errors')
return dict(form = form)

*is_in_set list checkboxes for view report (not related with database 
table) *
*e.g.*
def product_form():
redirect_url = 'report_product'

list_show_product = [('chart', T('Chart') ), 
('account', T('Account') ) ]

form = SQLFORM.factory(
Field("product", "reference product", 
 requires = IS_IN_DB(db, db.product.id, db.product._format, 
   zero = T('Choose One') ) ),
Field('show', 'list:string', 
 widget = SQLFORM.widgets.checkboxes.widget, 
 requires = IS_IN_SET(list_show_product, multiple = True) ) )
if form.process().accepted:
product = form.vars.product
show = form.vars.show
show.insert(0, product)

response.new_window = URL(redirect_url, args = show)
elif form.errors:
response.flash = T('Form has errors')
return dict(form = form)

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