Post

1 follower Follow
0
Avatar

optional field gives error when no value entered via API

Hello,

we are using podio to collect, store and manage data from our website. Whenever we have a form (not using podio forms, but costum html forms) that has optional from-fields, and these fields are not populated, we get the following error:

Error: Invalid field #### ('value'): Invalid value u'': Must be at least 1 characters long

This is the php code:

$podioapi->item->create($app_id, array('fields' => array(

"cat" => 7,

"message" => nl2br($_POST['message'], false),

"details" => $_POST['firstnmae'] . " " .$_POST['lastname'],

"email" =>$_POST['email'],

"phone" =>$_POST['phone'],

"date" => array('start' => date("Y-m-d H:i:s")),

"status" => 1),

));

In the above example the error would result from an empty email field...

When I enter data via podio I dont need to fill these fields. And how would the user fill this field with no data when using our webform.

Thank your for the help!

Michael Winterheller  

Michael Winterheller Answered

Please sign in to leave a comment.

2 comments

0
Avatar

Hi Michael

If the values are blank, you should simply leave them out of the "fields" array. So I suggest you start with an empty array, and then add the values if they are not blank, and the use that in the item-create call.

Christian

Christian Holm 0 votes
Comment actions Permalink
0
Avatar

Hi Christian,

thank you for the fast response!! I can follow your approach but how do I go about the "wanted" empty fields... But maybe the behavior is different when using the update call?!

Thank you again for the reponse

Michael

 

Michael Winterheller 0 votes
Comment actions Permalink