Re: Checkbox fields on server-side form posts

Anonymous
Not applicable

Checkbox fields on server-side form posts

Anyone have experience with checkbox fields on server side form posts? I have most of our forms are server-side form posts and I've never had any issues configuring them but now we are trying to use checkbox fields too and having a bit of an issue with getting them to match up.

My code looks like this for example:

<div class="row">

<div class="col-md-3">

<input type="checkbox" name="Gooru_Admin_WP__c" value="Gooru_Admin_WP__c" id="admin"><img width="199" height="112" src="http://www.thegooru.com/wp-content/uploads/google-apps.png">

</div>

Every other field is matching up okay, but the checkbox fields are just not yielding any results. Does anyone have experience with this? What am I setting up wrong?

I asked Marketo Support but they told me that server-side form posts are "outside the scope".

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Checkbox fields on server-side form posts

Rebekah, first note Marketo checkboxes are sent using variable formats.

  • If there is one checked box, it's sent using the name of the input.
  • If there is more than one checked box, they are all sent using the non-standard (yet extremely prevalent on the web) PHP array-push format: the name of the input plus square brackets ([])

What this means is that if you have two checked inputs with the same name:

<input type="checkbox" name="Gooru1" value="goo">

<input type="checkbox" name="Gooru1" value="foo">

then what goes on the wire is:

    &Gooru1[]=goo&Gooru1[]=foo

whereas if only one is checked:

     &Gooru1=foo

This differs from standard HTML forms which (in the absence of any JavaScript modding the data) will send the name of the input regardless of how many are checked.  Authors of apps designed for PHP back-ends usually add the [] to the end of form inputs manually, so the array-push format will always be sent.

Another difference from unadorned HTML forms is that a Marketo form will send the literal value "no" for an unchecked input.    A standard form will not send an unchecked input at all, which has been the bane of many a developer's existence.