/** * Creates a new lead and associates it with the contact * @param Contacts $contact * @param null|string $leadSource */ private static function generateLead(Contacts $contact, $leadSource = null) { $lead = new X2Leads('webForm'); $lead->firstName = $contact->firstName; $lead->lastName = $contact->lastName; $lead->leadSource = $leadSource; // disable validation to prevent saving from failing if leadSource isn't set if ($lead->save(false)) { $lead->createRelationship($contact); } }