/** * Validate form fields */ public function validate() { $this->validateTransferMethod(); if ($this->form->get('transfer_method')->getData() !== Distribution::TRANSFER_METHOD_NOT_FUNDING) { $this->validateDistributionMethod(); $this->validateFederalWithholding(); $this->validateStateWithholding(); parent::validate(); } }
/** * BIND event handler * Validate form fields * * @param FormEvent $event */ public function bind(FormEvent $event) { $data = $event->getData(); $form = $event->getForm(); if ($form->has('transfer_date_month') && $form->has('transfer_date_day')) { $month = $form->get('transfer_date_month')->getData(); $day = $form->get('transfer_date_day')->getData(); $year = date('Y'); if ($month && $day) { $date = new \DateTime($year . '-' . $month . '-' . $day); $data->setTransferDate($date); } } $validator = new ScheduledDistributionFormValidator($form, $data); $validator->validate(); if ($form->has('bankInformation')) { if (!$data->getBankInformation()) { $form->get('bankInformation')->addError(new FormError('Required.')); } else { $bankInformationValidator = new BankInformationFormValidator($form->get('bankInformation'), $data->getBankInformation()); $bankInformationValidator->validate(); } } }