protected function validateTransferFrom(FormInterface $form, TransferInformation $data) { $transferFrom = $data->getTransferFrom(); if (null === $transferFrom) { $form->get('transfer_from')->addError(new FormError('Required.')); } else { switch ($transferFrom) { case TransferInformation::TRANSFER_FROM_BROKERAGE_FIRM: $data->setTransferSharesCash(null); $data->setInsurancePolicyType(null); $data->setPenaltyAmount(null); $data->setRedeemCertificatesDeposit(null); break; case TransferInformation::TRANSFER_FROM_MUTUAL_FUND_COMPANY: if (null === $data->getTransferSharesCash()) { $form->get('transfer_shares_cash')->addError(new FormError('Required.')); } $data->setInsurancePolicyType(null); $data->setPenaltyAmount(null); $data->setRedeemCertificatesDeposit(null); break; case TransferInformation::TRANSFER_FROM_BANK: if (null === $data->getInsurancePolicyType()) { $form->get('insurance_policy_type')->addError(new FormError('Choose an option.')); } $data->setTransferSharesCash(null); $data->setRedeemCertificatesDeposit(null); break; case TransferInformation::TRANSFER_FROM_DEPOSIT_CERTIFICATES: if (null === $data->getRedeemCertificatesDeposit() || !$data->getRedeemCertificatesDeposit()) { $form->get('redeem_certificates_deposit')->addError(new FormError('Required.')); } $data->setTransferSharesCash(null); $data->setInsurancePolicyType(null); $data->setPenaltyAmount(null); break; } } }