I tried doing the specific fields like: form=SQLFORM.factory(db.patient(fields=['first_name']), db.emergencycontacts, db.dependents, formstyle = 'table3cols')
but that just throws an error saying no tables selected. I guess what I am trying to do is set certain fields to be show for each table and read the book but do not see how I would set it in my code as such. All of the examples I have seen so far show only 1 table at a time. On Mon, Jun 24, 2013 at 11:29 AM, Anthony <abasta...@gmail.com> wrote: > You can set the readable and writable attributes of the fields, or > .factory() can take a list of specific fields rather than entire tables. > > Anthony > > > On Monday, June 24, 2013 11:15:28 AM UTC-4, Tom Russell wrote: >> >> If I have a form factory with 3 tables, how would I define the fields I >> wanted shown for each? >> >> This is the code for my controller. I have tried to set it in several >> spots but all of them throw an error. >> >> def register_patient(): >> mark_not_empty(db.patient) >> mark_not_empty(db.**emergencycontacts) >> mark_not_empty(db.dependents) >> form=SQLFORM.factory(db.**patient, db.emergencycontacts, >> db.dependents, formstyle = 'table3cols') >> fs0=form[0][:28] # the first two name rows >> fs1=form[0][28:40] # the wine data rows (all but the last) >> fs2=form[0][40:45] # submit row (last) >> fs3=form[0][-1] # submit row (last) >> >> form.vars.medical_record_**number = 'KND' + str(date.today().year) + >> '0000' + str(random.randrange(1, 9999999+1)) >> >> form[0]=TABLE( >> FIELDSET(TAG.legend("Patient Info"),TABLE(fs0),_id="**register0"), >> FIELDSET(TAG.legend("Emergency Contact Info"),TABLE(fs1),_id="** >> register1"), >> FIELDSET(TAG.legend("**Dependents"),TABLE(fs2),_id="**register2"), >> TABLE(fs3)) >> if form.process().accepted: >> id = db.patient.insert(**db.**patient._filter_fields(form.** >> vars)) >> form.vars.patient=id >> id = db.emergencycontacts.insert(**** >> db.emergencycontacts._filter_**fields(form.vars)) >> response.flash='Thanks for filling the form' >> id = db.dependents.insert(**db.**dependents._filter_fields(** >> form.vars)) >> form.vars.dependents=id >> # and get a list of all persons >> redirect(URL('manage_patients'**)) >> >> style = STYLE(""".not_empty {color:#d00;}""") >> >> return dict(form=DIV(style,form)) >> >> >> Thanks. >> > -- > > --- > 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/groups/opt_out. > > > -- --- 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/groups/opt_out.