function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Praveen BonaluPraveen Bonalu 

'' is not a valid value for the type xsd:date using PHP tool kit salesforce(web to any object )

1) I have an HTML Form that post all the gathered information(I.e when the user enters the details and clicks on submit )it will post to the to the Php file for processing

2) The problem is when i am not passing any value to the date Fields I am getting the below error.

Errors: For date fields: is not a valid value for the type xsd:date

How can i make my Post to accept the Null value for the fields and have a successfully submit.

Form.html
<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <form class="form-horizontal" action="CandidateCreationPage.php" method="post" enctype="multipart/form-data">
        <!-- INFORMATION -->
        <div style="width:100%;background:#193b80;color:#fff;">
            <label style="padding:5px 0 0 15px">Information</label>
        </div>
        <div class="container">
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>First Name <span class="required-input letters-only">*</span></label></td>
                            <td>
                                <input class="required-field letters-only" type="text" name="firstname" id="first-name" maxlength="25" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Last Name <span class="required-input">*</span></label></td>
                            <td>
                                <input class="required-field letters-only" type="text" name="lastname" id="last-name" maxlength="30" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>How Did You Learn of This Opportunity? <span class="required-input">*</span></label></td>
                            <td>
                                <select class="required-field" id="hear-this-opportunity" name="hearthisopportunity">
                                    <option value="">--None--</option>
                                    <option value="Kijiji">Kijiji</option>
                                    
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Please Specify (If Applicable) <span id="please-specify-asterisk" class="required-input hide">*</span></label></td>
                            <td>
                                <input class="letters-only" type="text" name="pleasespecify" id="please-specify" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Status</label></td>
                            <td>
                                <select id="status" name="status">
                                    <option value="">--None--</option>
                                    <option value="Full-time">Full-time</option>
                                    <option value="Part-time">Part-time</option>
                                    
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Have You Worked With Us Before?</label></td>
                            <td>
                                <select id="worked-previously" name="workedpreviously">
                                    <option value="">--None--</option>
                                    <option value="Yes">Yes</option>
                                    <option value="No">No</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>When (If Applicable)</label></td>
                            <td>
                                <input type="date" name="workedpreviouslywhen" id="worked-previously-when" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Available to Start</label></td>
                            <td>
                                <input type="date" name="availabletostart" id="available-to-start" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Position <span class="required-input">*</span></label></td>
                            <td>
                                <select class="required-field" id="position" name="position">
                                    <option value="">--None--</option>
                                    <option value="driver">Driver</option>
                                    <option value="technician">Technician</option>
                                </select>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Primary Contact Number <span class="required-input">*</span></label></td>
                            <td>
                                <input class="required-field" type="tel" name="primarycontactnumber" id="primary-contact-number" maxlength="15" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Secondary Contact Number</label></td>
                            <td>
                                <input type="text" name="secondarycontactnumber" id="secondary-contact-number" maxlength="15" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Email</label></td>
                            <td>
                                <input type="email" name="email" id="email" maxlength="30" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- ADDRESS INFORMATION -->
        <div style="width:100%;background:#193b80;color:#fff;">
            <label style="padding:5px 0 0 15px">Address Information</label>
        </div>

        <div class="container">
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Street Address 1</label></td>
                            <td>
                                <input type="text" name="streetaddressone" id="street-address-one" maxlength="30" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Street Address 2</label></td>
                            <td>
                                <input type="text" name="streetaddresstwo" id="street-address-two" maxlength="30" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Province <span class="required-input">*</span></label></td>
                            <td>
                                <input class="required-field letters-only" type="text" name="province" id="province" maxlength="25" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>City <span class="required-input">*</span></label></td>
                            <td>
                                <input class="required-field letters-only" type="text" name="city" id="city" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Country</label></td>
                            <td>
                                <input type="text" name="country" id="country" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Postal Code</label></td>
                            <td>
                                <input type="text" name="postalcode" id="postal-code" maxlength="7" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- WORK EXPERIENCE -->
        <div style="width:100%;background:#193b80;color:#fff;">
            <label style="padding:5px 0 0 15px">Work Experience</label>
        </div>
        <div class="container">
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Currently Employed?</label></td>
                            <td>
                                <input type="checkbox" name="currentlyemployed" id="currently-employed" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Currently Employer</label></td>
                            <td>
                                <input type="text" name="currentemployer" id="current-employer" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Start Date</label></td>
                            <td>
                                <input type="date" name="startdateone" id="start-date-one" />
                            </td>
                        </tr>
                        <tr id="end-date-row">
                            <td class="label-cell"><label>End Date</label></td>
                            <td>
                                <input type="date" name="enddateone" id="end-date-one" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Rate of Pay</label></td>
                            <td>
                                <input type="number" name="rateofpayone" id="rate-of-pay-one" maxlength="20" />
                            </td>
                        </tr>
                    </tbody>
                </table>

                <table class="form-table" style="padding-top:25px;">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Previous Employer</label></td>
                            <td>
                                <input type="text" name="previousemployertwo" id="previous-employer-two" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Start Date</label></td>
                            <td>
                                <input type="date" name="startdatetwo" id="start-date-two" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>End Date</label></td>
                            <td>
                                <input type="date" name="enddatetwo" id="end-date-two" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Rate of Pay</label></td>
                            <td>
                                <input type="number" name="rateofpaytwo" id="rate-of-pay-two" maxlength="20" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Reason for Leaving</label></td>
                            <td>
                                <textarea name="reasonforleavingtwo" id="reason-for-leaving-two" maxlength="100"></textarea>
                            </td>
                        </tr>
                    </tbody>
                </table>

                <table class="form-table" style="padding-top:25px;">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Previous Employer</label></td>
                            <td>
                                <input type="text" name="previousemployerthree" id="previous-employer-three" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Start Date</label></td>
                            <td>
                                <input type="date" name="startdatethree" id="start-date-three" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>End Date</label></td>
                            <td>
                                <input type="date" name="enddatethree" id="end-date-three" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Rate of Pay</label></td>
                            <td>
                                <input type="number" name="rateofpaythree" id="rate-of-pay-three" maxlength="20" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Reason for Leaving</label></td>
                            <td>
                                <textarea name="reasonforleavingthree" id="reason-for-leaving-three" maxlength="100"></textarea>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- EDUCATION/QUALIFICATIONS -->
        <div style="width:100%;background:#193b80;color:#fff;">
            <label style="padding:5px 0 0 15px">Education / Qualifications</label>
        </div>
        <div class="container">
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Highest level of Education Obtained</label></td>
                            <td>
                                <select id="higher-education" name="highereducation">
                                    <option value="">--None--</option>
                                    <option value="University Degree">University Degree</option>
                                    <option value="College Diploma">College Diploma</option>
                                    <option value="Post-Grad Degree">Post-Grad Degree</option>
                                    <option value="High School">High School</option>
                                </select>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Licenses & Certifications</label></td>
                            <td>
                                <select id="licenses-and-certs" name="licensesandcerts" multiple="multiple">
                                    <optgroup label="Available">
                                        <option value="Forklift License">Forklift License</option>
                                        <option value="Technician License">Technician License</option>
                                        <option value="Apprentice">Apprentice</option>
                                        <option value="Valid Driver's License">Valid Driver's License</option>
                                        <option value="First Aid Training">First Aid Training</option>
                                    </optgroup>
                                </select>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

candidate.PHP
 
<?php
define("TOKEN_URL", "");
define("USERNAME", "");
define("PASSWORD", "");
define("SECURITY_TOKEN", "");
define("CLIENT_ID","");
define("CLIENT_SECRET","");
require_once ('soapclient/SforcePartnerClient.php');
$mySforceConnection = new SforcePartnerClient();
$mySforceConnection->createConnection("Partner.xml");
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
 
			
	$params = "grant_type=password&client_id=".CLIENT_ID

        . "&client_secret=" .CLIENT_SECRET . "&username=" . USERNAME
        . "&password=" . PASSWORD . SECURITY_TOKEN;
        //Get Access token
        $ch = curl_init(TOKEN_URL);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

        $json_response = curl_exec($ch);

        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        $response = json_decode($json_response, true);
        $access_token = $response['access_token'];
        $instance_url = $response['instance_url'];
		//var_dump($access_token);
		//var_dump( $instance_url);
		
?>
<div id="wrapper">
	<div id="page">
		<div id="page-bgtop">
			<div id="page-bgbtm">
				<div id="content">
					<div class="post">
						<div style="clear: both;">&nbsp;</div>
						<div class="entry">
								<a href="javascript:void(0);">							
								</a>							
								<?php
session_start();
if(isset($_POST["captcha"])&&$_POST["captcha"]!=""&&$_SESSION["code"]==$_POST["captcha"])
{
$query = "SELECT Id,Name,Status__c FROM Position__c WHERE  Name='".$_POST['position']."' LIMIT 1";
$response = $mySforceConnection->query($query);
$queryResult = new QueryResult($response);
if(isset($_POST['submit']))
{
try{
$fields = array (
'First_Name__c' => $_POST['firstname'],
'Last_Name__c' => $_POST['lastname'],
'Primary_contact_number__c'=>$_POST['primarycontactnumber'],
'Secondary_contact_number__c'=>$_POST['secondarycontactnumber'],
'Email__c'=> $_POST['email'],
'How_did_you_learn_of_this_Opportunity__c'=>$_POST['hearthisopportunity'],
'Please_Specify__c'=>$_POST['pleasespecify'],
'Status__c'=>$_POST['status'],
'Have_you_worked_with_us_before__c'=>$_POST['workedpreviously'],
'When__c'=>$_POST['workedpreviouslywhen'],
'Available_to_start__c'=>$_POST['availabletostart'],
'Position__c'=>$queryResult->records[0]->Id[0],									
'Street_Address_1__c'=>$_POST['streetaddressone'],
'Street_Address_2__c'=>$_POST['streetaddresstwo'],
'Province__c'=>$_POST['province'],
'City__c'=>$_POST['city'],
'Country__c'=>$_POST['country'],
'Postal_Code__c'=>$_POST['postalcode'],
'Currently_Employed__c'=>intval($_POST['currentlyemployed']),
'Current_Employer__c'=>$_POST['currentemployer'],
'Start_Date_Work_Exp1__c'=>$_POST['startdateone'],
'End_Date_Work_EXP_End1__c'=>$_POST['enddateone'],
'Rate_of_Pay_1__c'=>$_POST['rateofpayone'],
'Previous_Employer__c'=>$_POST['previousemployertwo'],
'Start_Date_Prev_Work_1__c'=>$_POST['startdatetwo'],
'End_Date_Prev_Wor_END_1__c'=>$_POST['enddatetwo'],
'Rate_of_Pay_2__c'=>$_POST['rateofpaytwo'],
'Reason_for_Leaving__c'=>$_POST['reasonforleavingtwo'],
'Previous_Employer_1__c'=>$_POST['previousemployerthree'],
'Start_Date_Prev_Work_2__c'=>$_POST['startdatethree'],
'End_Date_Prev_Wor_END_2__c'=>$_POST['enddatethree'],
'Rate_of_Pay_3__c'=>$_POST['rateofpaythree'],
'Reason_for_Leaving_1__c'=>$_POST['reasonforleavingthree'],
'Higher_Education__c'=>$_POST['highereducation'],
'Licenses_Certfications__c'=>$_POST['licensesandcerts'],												
	);
															
						
var_dump($fields);
 $sObject = new SObject();
 $sObject->fields = $fields;
 $sObject->type = 'Candidate__c';
 echo "**** Creating the following:\r\n";
 $createResponse = $mySforceConnection->create(array($sObject));
										 // print_r($createResponse);

} catch (Exception $e) {
echo $mySforceConnection->getLastRequest();
echo $e->faultstring;
	}
//Get the record id from last insert call and use that to make attachment call
$recordid = $createResponse[0]->id;

 
pconpcon
You shoud be checking to see if there is any value in the $_POST variable.  If there is not then you should not be setting that field on your object.