When using a computed field and SQLForm I was able to get the computed field to show up in the form by specifying the fields for the SQLForm, but whenever I submitted a value for the computed field, it always got overwritten by the computed Lambda. I only want the value "computed" when the field is left blank.
I realize I could do this on the controller level after form.accepts but due to other application restraints I'd rather do it on the model level if possible. On Sep 7, 6:10 am, "Ray (a.k.a. Iceberg)" <[email protected]> wrote: > On Sep 7, 3:00 am, Lennon <[email protected]> wrote: > > > > > > > > > > > I'm try to use alambdato set adefaultvaluebased on avaluein > > another table. Here is my model: > > > db.define_table('trip_instance', timestamp, sos_table, > > Field('trip_type_id', db.trip_type, label='Trip Type', > > widget=trip_select_widget, requires = IS_IN_DB(db, 'trip_type.id', '% > > (name)s'), represent=lambdaid:db.trip_type(id)['name']), > > Field('total_slots', 'integer',default=lambdar: > > db.trip_type(r.trip_type_id)['total_slots']), > > > Locally this causes an error that says: > > > TypeError: <lambda>() takes exactly 1 argument (0 given) > > > And on my server (Linode) there is no error but when I try and create > > a new trip instance with sqlform the total slots field is pre- > > populated with this: > > > <function <lambda> at 0x7f27684b7140> > > > Mylambdalooks almost identical to the one that works fine for > > represent in the trip_type_id field except I'musingthe table instead > > of the field. Is that what I'm doing wrong? > > Looks like thedefaultparameter does not want alambda. Try to give > it a computedvalueinstead. > > Regards, > Ray

