Checkboxes with apply_joborder

67 views
Skip to first unread message

TBP

unread,
Oct 19, 2016, 9:52:03 AM10/19/16
to CATS API
When a field is retrieved through `get_joborder_applications` which only contains checkboxes, the POST data which is sent to `apply_joborder` (with a few checked boxes) looks something like this:

["field_53799_157290"] => "yes"
["field_53799_157292"] => "yes"
["field_53799_157488"] => "yes"

On return an error appears: '53799 is a required parameter', although field_53799 is not an input and just contains checkboxes. How is the data supposed to be sent? The documentation for http://api.catsone.nl/api/apply_joborder doesn't give any details.

Aaron Baluczynski

unread,
Oct 20, 2016, 2:39:59 PM10/20/16
to CATS API
HI,

The value needs to be submitted as an array. For example:

field_53799[]=157290&field_53799[]=157292

Aaron

TBP

unread,
Oct 25, 2016, 7:08:42 AM10/25/16
to CATS API
Thanks for your reply. When requesting the form through `get_joborder_applications?transaction_code=xxx&id=xxx&form=true`, the output is as follows:

<input type="checkbox" name="field_53799_157490" class="{class}"/>
<input type="checkbox" name="field_53799_157464" class="{class}"/>
<input type="checkbox" name="field_53799_157316" class="{class}"/>

If I understand correctly this all needs to be changed to the following?

<input type="checkbox" value="157490" name="field_53799[]" class="{class}"/>
<input type="checkbox" value="157464" name="field_53799[]" class="{class}"/>
<input type="checkbox" value="157316" name="field_53799[]" class="{class}"/>

Why isn't the output like this in the first place I wonder? :)

Op donderdag 20 oktober 2016 20:39:59 UTC+2 schreef Aaron Baluczynski:

TBP

unread,
Oct 27, 2016, 8:00:45 AM10/27/16
to CATS API
Hi Aaron,

Can you confirm the response data needs to be transformed this way? Thanks in advance.

Op dinsdag 25 oktober 2016 13:08:42 UTC+2 schreef TBP:

Aaron Baluczynski

unread,
Oct 27, 2016, 10:07:25 AM10/27/16
to CATS API
That looks about right. You can do it there in the HTML or transform it on the backend.

JuniorDev

unread,
Oct 31, 2016, 11:47:15 PM10/31/16
to CATS API
Hi TCP can you email me on "jamilj...@gmail.com" Id like to ask you something about your form please.

CHeers

TBP

unread,
Nov 23, 2016, 3:20:22 AM11/23/16
to CATS API
Hi Aaron,

Seems like this is still not working. De HTML output is transformed like you proposed:

<input value="157490" type="checkbox" id="field_53799_157490" name="field_53799[]">
<input value="157464" type="checkbox" id="field_53799_157464" name="field_53799[]">
<input value="157316" type="checkbox" id="field_53799_157316" name="field_53799[]">

API call body:

["field_53799"] => array(3) {
   
[0] => string(6) "157490"
   
[1] => string(6) "157464"
   
[2] => string(6) "157316"
}

But the values are not coming through when sent to CATS through apply_joborder. Can you check what is wrong?

Op donderdag 27 oktober 2016 16:07:25 UTC+2 schreef Aaron Baluczynski:

TBP

unread,
Nov 28, 2016, 11:00:15 AM11/28/16
to CATS API
Did you get a chance yet to take a look at the last reply?

Thanks!


Op donderdag 27 oktober 2016 16:07:25 UTC+2 schreef Aaron Baluczynski:
That looks about right. You can do it there in the HTML or transform it on the backend.

Aaron Baluczynski

unread,
Nov 28, 2016, 2:44:08 PM11/28/16
to CATS API
Sorry I didn't reply sooner. Are you getting an error or is everything else working and the field just isn't populating?

TBP

unread,
Nov 29, 2016, 3:44:10 AM11/29/16
to CATS API
The fields aren't mandatory, so there's no error. The checked boxes are just not populated when viewed in CATS.

Op maandag 28 november 2016 20:44:08 UTC+1 schreef Aaron Baluczynski:

Aaron Baluczynski

unread,
Nov 29, 2016, 10:04:10 AM11/29/16
to CATS API
I went ahead and sent a test application via API v2 to your site, which created candidate 4840034. As you can see it worked correctly. I would suggest you inspect the actual POST data that is being sent to the API.

Aaron

TBP

unread,
Nov 29, 2016, 11:56:48 AM11/29/16
to CATS API
Hi Aaron,

Thanks. Can you specify what is wrong with this HTML output and POST data? This way I'll know what to change to successfully submit the checkboxes:

HTML
<input value="157490" type="checkbox" id="field_53799_157490" name="field_53799[]">
<input value="157464" type="checkbox" id="field_53799_157464" name="field_53799[]">
<input value="157316" type="checkbox" id="field_53799_157316" name="field_53799[]">

POST data
["field_53799"] => array(3) {
   
[0] => string(6) "157490"
   
[1] => string(6) "157464"
   
[2] => string(6) "157316"
}

Op dinsdag 29 november 2016 16:04:10 UTC+1 schreef Aaron Baluczynski:

Aaron Baluczynski

unread,
Nov 29, 2016, 12:00:20 PM11/29/16
to CATS API
Those values look fine, but I need to see the actual POST data that is being sent in the request, not the PHP representation of it before you send it off.

Aaron

TBP

unread,
Dec 1, 2016, 4:59:31 AM12/1/16
to CATS API
Example of part of the POST body:

------WebKitFormBoundaryoLbWe8UJ1sfcWenD
Content-Disposition: form-data; name="field_53799[]"
157490

------WebKitFormBoundaryoLbWe8UJ1sfcWenD
Content-Disposition: form-data; name="field_53799[]"
157464

------WebKitFormBoundaryoLbWe8UJ1sfcWenD
Content-Disposition: form-data; name="field_53799[]"
157316

Op dinsdag 29 november 2016 18:00:20 UTC+1 schreef Aaron Baluczynski:

Aaron Baluczynski

unread,
Dec 1, 2016, 4:37:06 PM12/1/16
to CATS API
Thanks for sending that. It certainly does look right. I'm not sure what could be going on here, but I have added some more logging to help diagnose the problem. Could you send a few test requests?

Aaron Baluczynski

unread,
Dec 1, 2016, 7:24:28 PM12/1/16
to CATS API
I am able to reproduce the bug now, so there's no need to send test requests. I'll let you know when I've found the fix.

Aaron Baluczynski

unread,
Dec 2, 2016, 2:40:49 PM12/2/16
to CATS API
Turns out I was sending bad data, which explains why it wasn't working for me. Otherwise it seems to be functioning correctly.

Can you send a couple test requests? That will help me figure out what's going on with your request. Thanks.

TBP

unread,
Dec 5, 2016, 6:57:17 AM12/5/16
to CATS API
Thanks for the response. I've sent three test requests:

- One for CATS ID '254252' (te...@example.com)
- One for CATS ID '253328' (te...@example.com
- One general registration (te...@example.com)

Op vrijdag 2 december 2016 20:40:49 UTC+1 schreef Aaron Baluczynski:

Aaron Baluczynski

unread,
Dec 5, 2016, 10:12:50 AM12/5/16
to CATS API
Thanks for sending those tests. Here's what I got as POST data:

array(10) {
'field_43407' =>
string(6) "Test 2"
'field_43410' =>
string(6) "Test 2"
'field_43413' =>
string(17) "te...@example.com"
'field_43428' =>
string(10) "0612345678"
'field_53799' =>
string(5) "Array"
'field_53805' =>
string(5) "Array"
'field_53808' =>
string(10) "2016-12-05"
'id' =>
string(6) "253328"
'transaction_code' =>
string(32) "..."
}

You'll see that your code is sending the string "Array" instead of passing the array values.

TBP

unread,
Dec 6, 2016, 4:01:16 AM12/6/16
to CATS API
Thanks for the reply, it's more clear now how the data is interpreted. I've sent another request (ID '254252', 'te...@example.com), could you maybe check again?

Op maandag 5 december 2016 16:12:50 UTC+1 schreef Aaron Baluczynski:

Aaron Baluczynski

unread,
Dec 6, 2016, 9:54:50 AM12/6/16
to CATS API
Data looks correct.

TBP

unread,
Dec 20, 2016, 3:24:12 AM12/20/16
to CATS API
I've sent a few additional @example.com requests so the client can verify if the checkboxes are showing in CATS, but he indicates they are still empty. Can you tell me what change is needed for them to show up in CATS?

Op dinsdag 6 december 2016 15:54:50 UTC+1 schreef Aaron Baluczynski:
Data looks correct.

Aaron Baluczynski

unread,
Dec 20, 2016, 10:29:06 AM12/20/16
to CATS API
Oh, I see the issue. The values are showing in the application but not in the custom field on the profile. I've pushed a fix for this bug. Please try submitting your data again.
Reply all
Reply to author
Forward
0 new messages