I've put this into the controller to test this out: def create_newbuild(): #newbuild and resale properties share the same table. #the extraneous fields are rendered non-writable by the below db.property.land.writable = False db.property.reference_number.writable = False db.property.habitable_area.writable = False db.property.utilities.writable = False db.property.address.writable = False db.property.postcode.writable = False db.property.land.readable = False db.property.reference_number.readable = False db.property.habitable_area.readable = False db.property.utilities.readable = False db.property.address.readable = False db.property.postcode.readable = False db.property.property_type.default="2" #select the newbuild property type and hide the option from the user db.property.property_type.readable = False form=SQLFORM(db.property) if form.process().accepted: response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' else: response.flash = 'please fill out the form' return dict(form=form)
Strange thing is though that the property_type field still appears on the form. Any ideas why? Thank you, Chris On Wed, Apr 18, 2012 at 3:43 PM, Chris Rowson <christopherrow...@gmail.com>wrote: > Thanks for confirming this for me, this did seem to be the most sensible > way to approach the problem :-) > > Chris > > > On Wed, Apr 18, 2012 at 1:04 AM, simon <simo...@gmail.com> wrote: > >> You can do this with a single form. At the top of the controller set >> readable=false, writable=false for the fields you do not want on the form. >> >> On Tuesday, 17 April 2012 23:44:54 UTC+1, leftcase wrote: >> >>> I'm a new adopter of web2py and I'm trying to learn the framework by >>> building a simple property site. >>> >>> I have two types of properties, new or old. >>> >>> New properties have a few core attributes, let's say name, price, >>> location, bedrooms >>> >>> Old properties have the same core attributes with a few more added on, >>> for instance utilities, land, lease type. >>> >>> I've tried making a table for new properties and a table for old >>> properties but it seems to complicate things if I for instance want to list >>> all types of properties (new and old) and order by price (I've been >>> struggling to figure out how to aggregate the results from both tables then >>> order by price). >>> >>> Would it make more sense to have one table with all of the fields for >>> new and old properties and simply create two different forms with different >>> fields exposed depending on whether or not the user wants to create a new >>> or an old property? >>> >>> Thanks in advance, >>> >>> Chris >>> >> >