J. Craig Williams
J. Craig Williams

Reputation: 410

How to set checkbox to false (Gravity Forms > PHP API > Smartsheet)

I've inherited some PHP code written for a Gravity Forms form in WordPress. The PHP code uses the Smartsheet API to update rows in Smartsheet. The previous code did not recognize Smartsheet's checkboxes.

I've got that working.

However, I have not figured out how to set a checked checkbox false.

There's lots of code, but these (I believe) are the important lines:

    $data = array();
//snip    
        foreach($feed['meta'] as $key => $entry_key) {
//snip
            $colid = str_replace("mappedFields_","",$key);
//snip
            $data[$colid] = substr($entry[$entry_key], 0,
                 strpos($entry[$entry_key], "|"));

What I have tried to do is force the

$data[$colid]

to various values on the PHP side. I've tried false, "false", 0, even text.

I've tried various fields on the Gravity Form's side, without success. I've tried intercepting the value in the PHP code before it is sent to Smartsheet.

If the value is false or 0, then it does not get passed to Smartsheet. If I pass "false" or some other value, then the API throws the 1042 error on checkboxes.

Any help is appreciated.

Craig

Upvotes: 0

Views: 751

Answers (1)

stmcallister
stmcallister

Reputation: 1719

Not sure what the rest of your code is doing with your request, but sending the value of false should uncheck the CHECKBOX cell.

You could also set the strict attribute for your cell to false. This would allow you to send the string "false" to the CHECKBOX cell, which should uncheck the checkbox in your sheet.

You can read more about the strict cell attribute in the Cell Value Parsing of the Smartsheet API Documentation

Upvotes: 2

Related Questions