Use of the :records variable type and ZSQL methods
I am trying to take in a form that has multiple records like this: <FORM ACTION=add_records> Field1<INPUT TYPE="text" NAME="testlist.Field1:records:ignore_empty" SIZE="30"> Field2<INPUT TYPE="text" NAME="testlist.Field2:records:ignore_empty" SIZE="30"><br> Field1<INPUT TYPE="text" NAME="testlist.Field1:records:ignore_empty" SIZE="30"> Field2<INPUT TYPE="text" NAME="testlist.Field2:records:ignore_empty" SIZE="30"><br> Field1<INPUT TYPE="text" NAME="testlist.Field1:records:ignore_empty" SIZE="30"> Field2<INPUT TYPE="text" NAME="testlist.Field2:records:ignore_empty" SIZE="30"><br> <INPUT TYPE="submit" VALUE="go" </FORM> I want to loop through the records on the add_records page. It works fine if I do this and just display them: <table> <dtml-in testlist> <tr> <td><dtml-var Field1 missing></td><td><dtml-var Field2 missing></td> </tr> </dtml-in> </table> I get the following error if I try looping it through a ZSQL Method: Error Type: Bad Request Error Value: ['Field1', 'Field2'] Here is the code I used and sqlTest is the ZSQL Method that just inserts the two fields into a test DB: <dtml-in testlist> <dtml-call sqlTest> </dtml-in> What am I doing wrong? Calvin
Error Type: Bad Request Error Value: ['Field1', 'Field2']
Here is the code I used and sqlTest is the ZSQL Method that just inserts the two fields into a test DB:
<dtml-in testlist> <dtml-call sqlTest> </dtml-in>
What am I doing wrong?
you'll have to feed a named argument to your Zsql method (that is in its definition). In this case that would be testlist. Then it should work as expected hth Rik
Error Type: Bad Request Error Value: ['Field1', 'Field2']
Here is the code I used and sqlTest is the ZSQL Method that just inserts the two fields into a test DB:
<dtml-in testlist> <dtml-call sqlTest> </dtml-in>
What am I doing wrong?
you'll have to feed a named argument to your Zsql method (that is in its definition). In this case that would be testlist. Then it should work as expected
Here is the Z SQL Method. It takes the arguments Field1 and Field2. INSERT INTO Test_Fields (Field1,Field2) VALUES ( <dtml-sqlvar Field1 type=nb optional>, <dtml-sqlvar Field2 type=nb optional> ) Am I calling testlist incorrectly? I have tried forcing the namespace with the dtml-with tag, but it doesn't seem to be making any difference. Are the arguments field in the Method what you are refering to when you say named argument? Thanks, Calvin
Calvin Parker wrote:
Error Type: Bad Request Error Value: ['Field1', 'Field2']
Here is the code I used and sqlTest is the ZSQL Method that just inserts the two fields into a test DB:
<dtml-in testlist> <dtml-call sqlTest> </dtml-in>
What am I doing wrong?
you'll have to feed a named argument to your Zsql method (that is in its definition). In this case that would be testlist. Then it should work as expected
Here is the Z SQL Method. It takes the arguments Field1 and Field2.
that's where the problem is: in your REQUEST there _are_ no Field1 and Field2: they are in the testlist (pseudo) dictionary. <notreallytestedbutshouldwork> Make you method (something like): <dtml-in testlist> INSERT INTO Test_Fields (Field1,Field2) VALUES ( <dtml-sqlvar Field1 type=nb optional>, <dtml-sqlvar Field2 type=nb optional> ) </dtml-in> </notreallytestedbutschouldwork>
Am I calling testlist incorrectly? I have tried forcing the namespace with the dtml-with tag, but it doesn't seem to be making any difference. Are the arguments field in the Method what you are refering to when you say named argument?
I think so (terminology is a bit confusing here). ZSQL methods only take named arguments. There has been quite a bit of threads on this on the list. SO you might want to search the archives for them. In this case the named argument would have to be testlist, as this is the argument REQUEST contains. Rik
participants (2)
-
Calvin Parker -
Rik Hoekstra