It works when I use it so I am not sure. Can you isolate the problem? Can you provide a simpler model/controller to reproduce the problem?
On May 26, 9:22 am, ggivler <ggiv...@gmail.com> wrote: > Tried the reference thing but that doesn't work. I am still not sure > why your code does not put the values in the database, just the > separators so I get field with "|||" in them. But I can handle that in > the routine below and update record. That will let me read it back > out, I know this is a hack but it will get me one step closer to my > goal which is a finished product. > > The problem I believe comes from the jquery multiselect code, it > renames the dropdown to add a "[]" at the end, and this causes Python > a world of problems. Mr. Freeze had a solution so I used his, if you > call the request.vars dictionary with dictionary syntax having an name > with "[]" tacked on the end is not a problem. > > As I said, I sort of had to hack a solution, I borrowed some stuff > from mr. freeze's multiselect solution in web2pyslices > > if request.vars['testcase_test_testtypeids[]'] is not None: > if len(request.vars['testcase_test_testtypeids[]']) > 0: > for testtypeid in > request.vars['testcase_test_testtypeids[]']: > > db.testcase_testtypes.insert(testcaseid=insertid,testtypeid=testtypeid,recordvalid='T') > print db._lastsql > > See the problem I have is the the testtype table is basically just a > source table to tell the page what values to display. Then I have a > many to many relationship between testcases and testtypes. > > On May 25, 9:02 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > Not sure but this is a problem I see > > > db.testcase_test.testtypeids.requires = IS_IN_DB(testtypes, > > 'testtype.id', 'testtype.name',multiple=True) > > > implies db.testcase_test.testtypeids stored the texttype.id therefore > > it should be of type reference to db.testtype and not type 'string' > > > On May 25, 4:47 pm, ggivler <ggiv...@gmail.com> wrote: > > > > I am using the multiselect plugin read and save data from a > > > crud.create or crude.update form and it just is not working, it seems > > > to see that there are values there as the field is filled with a "|" > > > for each option selected. I am not sure what is happening and what I > > > am doing wrong. Any help would be appreciated. > > > If I manually fill data into the database and load it using > > > crud.update(db.testcase_test, testcase_id) it selects the correct > > > options. I am sure I am missing something stupid and anyone who wants > > > to point it out would be greatly appreciated. > > > > Here is the database table > > > > db.define_table('testtype', > > > Field('name', 'string', length=45), > > > Field('description', 'text'), > > > Field('recordvalid', 'boolean'), > > > migrate=False) > > > > db.define_table('testcase_test', > > > Field('structure', 'string', length=1024,writable=False), > > > Field('name', 'string', length=255), > > > Field('description', 'text', length=255), > > > Field('testmodeid', db.testmode, > > > requires=IS_IN_DB(db,'testmode.id','testmode.name')), > > > Field('testtoolid', db.testtool, > > > requires=IS_IN_DB(db,'testtool.id','testtool.name')), > > > Field('inputconfigblobid', db.inputblob, > > > requires=IS_IN_DB(db,'inputblob.id', 'inputblib.localfilename')), > > > Field('requirementsid', db.requirements, > > > requires=IS_IN_DB(db,'requirements.id','requirements.name')), > > > Field('productid',writable=True), > > > Field('environmentid',writable=True), > > > Field('commandline', 'string', length=255), > > > Field('resulttypeid', db.resultstype, > > > requires=IS_IN_DB(db,'resultstype.id', 'resultstype.resulttype')), > > > Field('resultunitsid', db.resultunits, > > > requires=IS_IN_DB(db,'resultunits.id', 'resultunits.unit')), > > > Field('lowlimit', 'string', length=255), > > > Field('highlimit', 'string', length=255), > > > Field('estexectime', 'time'), > > > Field('lastexectime', 'time', writable=False), > > > Field('priority','integer',default=-1), > > > Field('default_priority', 'integer', default=-1), > > > Field('seqnum', 'integer',default=-1), > > > Field('testtypeids', 'string'), > > > migrate=True) > > > db.testcase_test.structure.label = 'Test Stuite Structure' > > > db.testcase_test.testmodeid.label = 'Test Mode' > > > db.testcase_test.testtoolid.label = 'Test Tool' > > > db.testcase_test.inputconfigblobid.label = 'Test Case Input Config > > > File' > > > db.testcase_test.requirementsid.label = 'Test Case Requirements' > > > db.testcase_test.productid.label = 'Product' > > > db.testcase_test.commandline.label = 'Test Case Commandline' > > > db.testcase_test.resulttypeid.label = 'Result Type' > > > db.testcase_test.resultunitsid.label = 'Result Units' > > > db.testcase_test.lowlimit.label = 'Low Limit' > > > db.testcase_test.highlimit.label = 'High Limit' > > > db.testcase_test.estexectime.label = 'Estimated Execution Time' > > > db.testcase_test.lastexectime.label = 'Last Execution Time' > > > db.testcase_test.seqnum.label = 'Sequence Number' > > > db.testcase_test.testtypeids.label = 'Test Types' > > > products = db(db.testsuite.parentid==-1) > > > db.testcase_test.productid.requires = IS_IN_DB(products, > > > 'testsuite.id', 'testsuite.name') > > > environments = db(db.testenvironment.recordvalid=='T') > > > db.testcase_test.environmentid.requires = IS_IN_DB(environments, > > > 'testenvironment.id', 'testenvironment.name') > > > testtypes = db(db.testtype.recordvalid=='T') > > > db.testcase_test.testtypeids.requires = IS_IN_DB(testtypes, > > > 'testtype.id', 'testtype.name',multiple=True) > > > > Here is the form code: > > > def test_case(): > > > form = None > > > db.testcase_test.structure.default = > > > session.testsuite_testsuitestructure > > > db.testcase_test.productid.default = session.testsuite_productid > > > for row in > > > db(db.testenvironment.name==session.testsuite_environmentname).select(): > > > db.testcase_test.environmentid.default = row.id > > > #script = SCRIPT("$(document).ready(function() {$ > > > ('#testcase_test_testtypeids').multiSelect();} > > > );",_language="javascript",_charset="utf-8") > > > if len(request.args) > 0: > > > if request.args[0] == 'edit': > > > testcase_mode = request.args[0] > > > testcase_id = request.args[1] > > > form = crud.update(db.testcase_test,testcase_id) > > > else: > > > form = crud.create(db.testcase_test) > > > > return dict(form=form,session=session) > > > > Here is the view code: > > > {{extend 'layout.html'}} > > > <h1>Test Case</h1> > > > {{=form}} > > > {{=plugin_multiselect(db.testcase_test.testtypeids)}} > > > <h2>Submitted variables</h2> > > > {{=BEAUTIFY(request.vars)}} > > > > <h2>Session variables</h2> > > > {{=BEAUTIFY(session)}}