API - subscription form - checkbox values

adamx

Member
Hello,

I've been trying a lot to get this working but I am forced to ask for help here.

So, for the checkboxes, the value is sent ok with:
Code:
       'ORIENT' => isset($_POST['ORIENT']) ? $_POST['ORIENT'] : null,
and the form with:
Code:
<div class="data">
                <label for="ORIENT_0"><input value="ADA" id="ORIENT_0" type="radio" name="ORIENT"><span>ADAM</span></label>
                <label for="ORIENT_1"><input value="AFA" id="ORIENT_1" type="radio" name="ORIENT"><span>AFAM</span></label>
                <label for="ORIENT_2"><input value="AGA" id="ORIENT_2" type="radio" name="ORIENT"><span>AGAM</span></label>
                <label for="ORIENT_3"><input value="AHA" id="ORIENT_3" type="radio" name="ORIENT"><span>AHAM</span></label>
            </div>

but the problem appear when trying to send the checkboxes.
Code:
       'INTR'    => isset($_POST['INTR']) ? $_POST['INTR'] : null,
with:
Code:
<div class="data2">
                    <label for="INTR_0"><input value="BUH" id="INTR_0" type="checkbox" name="INTR[]"><span>BUHE</span></label>
                    <label for="INTR_1"><input value="BUN" id="INTR_1" type="checkbox" name="INTR[]"><span>BUNE</span></label>
                    <label for="INTR_2"><input value="BUM" id="INTR_2" type="checkbox" name="INTR[]"><span>BUME</span></label>
 
                </div>

Does nothing in the form. The form is sent, the email, fname, radioboxes all ok, but checkboxes remain unchecked.

Any help is much appreciated.
 
In chrome browser inspector it shows
EMAIL=adam%40xhardy.com&FNAME=adam&INTR%5B%5D=EVNTS&INTR%5B%5D=PROD&INTR%5B%5D=QTIME

More than that I can't tell you cose I am not a programmer and actually have no idea whats what. I asked a programmer and he had no more luck than I did.
My question is... if you have a form with checkboxes, how should we send it, based on the ajax_subscribe example from the sdk?
 
So if you use the API and you have a subscription form with checkboxes, the solution is:
Code:
       'FIELDNAME'   => (!empty($_POST['FIELDNAME']) && is_array($_POST['FIELDNAME'])) ? array_values($_POST['FIELDNAME']) : null,

Thank you @twisted1919 for your help!
 
Back
Top