def list_order_type():
if 'edit' in request.args:
record = db.foobar(request.args(-1, cast=int))
older_than_an_hour = record.created_on < request.now - datetime.
timedelta(hours=1)
db.foobar.text.writable = not (record.text and older_than_an_hour)
form = SQLFORM.grid(db.foobar)
return dict(form=form)
Anthony
On Thursday, May 26, 2016 at 5:46:45 AM UTC-4, Mike Constabel wrote:
>
> Hello,
>
> I try to find a solutiuon for a hopefully simple problem.
>
> Example:
>
> db.define_table("foobar",
> Field("uuid", "string"),
> Field("text", "string"),
> Field('created_on', "datetime", default=request.now))
>
> def list_order_type():
> form = SQLFORM.grid(db.foobar)
> return dict(form=form)
>
> I need that in the edit page of the grid the field "text" is readonly if
> the field "text" is not empty and the "created_on" timestamp id older than
> an hour.
>
> Where and how can I set the db.foobar.text.writable = False?
>
> I can use request.args(1) = 'edit', but how can I then take the row, test
> it and set the writable to false?
>
> I don't want to validate after sending the form. The input field should be
> initially readonly.
>
>
> Regards,
> Mike
>
>
--
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.