is default value request.now is work in SQLFORM.grid (edit) ?
e.g.
*models/db.py*
def on_define_employee(table): 
# default
table.status.default = 'New'
# notnull
table.full_name.notnull = True
table.status.notnull = True
# required
table.full_name.required = True
table.status.required = True
# requires
table.full_name.requires = IS_NOT_EMPTY()
table.status.requires = IS_IN_SET([('New', T('New') ), 
  ('Request AOC', T('Request AOC') ), 
  ('Active', T('Active') ), 
  ('Resign', T('Resign') ) ] )

db.define_table('employee', 
Field('full_name'), 
Field('aoc', 'date'), 
Field('status'), 
auth.signature,
on_define = on_define_employee, 
format = '%(full_name)s')

*controllers/hr.py*
def employee():
table = db.employee
table.status.requires = IS_IN_SET([('New', T('New') ), 
  ('Request AOC', T('Request AOC') ), 
  ('Resign', T('Resign') ) ] )
grid = SQLFORM.grid(table)
return locals()

*controllers/it.py*
def employee():
table = db.employee

# default
table.aoc.default = request.now

# requires
table.aoc.requires = IS_DATE()
table.status.requires = IS_IN_SET([('Active', T('Active') ) ] )

# writable
table.full_name.writable = False

query = table.status == 'Request AOC'

grid = SQLFORM.grid(query)
return locals()

*logic flow*
hr user create/add/input employee data in hr controller
e.g.
full name : john
status : Request AOC

then when it user edit the employee data, the default value = request.now 
is empty, not show current date (no error occured, the result is not 
expected), is it normal or i missed something in my code? what i want to 
achieve is when it user edit the employee data in SQLFORM.grid, the aoc is 
show the current date.

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