/** * @param FormInterface $form * @param GitHubIssue $data */ protected function addAssignedToField($form, $data) { if ($data->getAssignedTo()) { $targetEntity = $data->getAssignedTo()->getPartner(); } else { $targetEntity = $this->getTargetEntityFromRequest(); } if ($targetEntity instanceof Partner) { $gitHubAccounts = $targetEntity->getGitHubAccounts(); } // Add selection of GitHub accounts to assign the issue to, // if there are more than one available for the target entity if ($gitHubAccounts) { if (count($gitHubAccounts) > 1) { $form->add('assignedTo', 'entity', ['required' => true, 'label' => 'orocrm.partner.form.github_account.label', 'class' => 'OroCRMPartnerBundle:GitHubAccount', 'choices' => $gitHubAccounts]); } elseif (!$data->getAssignedTo() && count($gitHubAccounts) == 1) { $data->setAssignedTo($gitHubAccounts->first()); } } }