private function createClientPersonalInformation(array $data, User $clientUser) { $personalInformation = new PersonalInformation(); $personalInformation->setClient($clientUser); $personalInformation->setSsnTin($data['ssn_tin']); $personalInformation->setIncomeSource($data['income_source']); $personalInformation->setEmployerName($data['employer_name']); $personalInformation->setIndustry($data['industry']); $personalInformation->setOccupation($data['occupation']); $personalInformation->setBusinessType($data['business_type']); $personalInformation->setEmployerAddress($data['employer_address']); $personalInformation->setCity($data['city']); $personalInformation->setZipcode($data['zipcode']); return $personalInformation; }
protected function validateEmploymentType(FormInterface $form, $data) { if ($form->has('employment_type')) { $employmentType = $form->get('employment_type')->getData(); if (!in_array($employmentType, array_keys(Profile::getEmploymentTypeChoices()))) { $form->get('employment_type')->addError(new FormError('Required.')); } else { if ($employmentType == Profile::CLIENT_EMPLOYMENT_TYPE_RETIRED || $employmentType == Profile::CLIENT_EMPLOYMENT_TYPE_UNEMPLOYED) { $data->setEmployerName(null); $data->setIndustry(null); $data->setOccupation(null); $data->setBusinessType(null); $data->setEmployerAddress(null); $data->setEmploymentCity(null); $data->setEmploymentState(null); /* if ($form->has('zipcode')) { $data->setEmploymentZip(null); }*/ if (!in_array($data->getIncomeSource(), PersonalInformation::getIncomeSourceChoices())) { $form->get('income_source')->addError(new FormError('Required.')); } } else { $data->setIncomeSource(null); $employerName = $data->getEmployerName(); $industry = $data->getIndustry(); $occupation = $data->getOccupation(); $businessType = $data->getBusinessType(); $employerAddress = $data->getEmployerAddress(); $city = $data->getEmploymentCity(); $state = $data->getEmploymentState(); if (is_null($employerName) || !is_string($employerName)) { $form->get('employer_name')->addError(new FormError('Required.')); } if (is_null($industry) || !is_string($industry)) { $form->get('industry')->addError(new FormError('Required.')); } if (is_null($occupation) || !is_string($occupation)) { $form->get('occupation')->addError(new FormError('Required.')); } if (is_null($businessType) || !is_string($businessType)) { $form->get('business_type')->addError(new FormError('Required.')); } if (is_null($employerAddress) || !is_string($employerAddress)) { $form->get('employer_address')->addError(new FormError('Required.')); } if (is_null($city) || !is_string($city)) { $form->get('employment_city')->addError(new FormError('Required.')); } if ($form->has('employment_state')) { if (null === $state) { $form->get('employment_state')->addError(new FormError('Required.')); } } if ($form->has('employment_zip')) { $zipDigits = 5; $zip = str_replace(array(' ', '-'), '', $data->getEmploymentZip()); if (!is_numeric($zip)) { $form->get('employment_zip')->addError(new FormError("Enter correct zip code.")); } elseif (strlen($zip) != $zipDigits) { $form->get('employment_zip')->addError(new FormError("Zip code must be {$zipDigits} digits.")); } else { $data->setEmploymentZip($zip); } } } } } }