Skip to content

Instantly share code, notes, and snippets.

Created April 16, 2014 23:32
Show Gist options
  • Save anonymous/08bf222baa5c250b4614 to your computer and use it in GitHub Desktop.
Save anonymous/08bf222baa5c250b4614 to your computer and use it in GitHub Desktop.
<?php
namespace UsaRugbyStats\Competition\Form\Fieldset\Union;
use Doctrine\Common\Persistence\ObjectManager;
use DoctrineModule\Form\Element\ObjectSelect;
use Zend\Form\Fieldset;
use Doctrine\Common\Persistence\ObjectRepository;
use Zend\InputFilter\InputFilterProviderInterface;
class TeamFieldset extends Fieldset implements InputFilterProviderInterface
{
protected $teamRepo;
public function __construct(ObjectManager $om, ObjectRepository $mapper)
{
parent::__construct('team');
$this->teamRepo = $mapper;
$team = new ObjectSelect();
$team->setName('id');
$team->setOptions(array(
'label' => 'Team',
'object_manager' => $om,
'target_class' => 'UsaRugbyStats\Competition\Entity\Team',
));
$this->add($team);
}
public function getTeam($teamid = NULL)
{
if (empty($teamid)) {
$teamid = $this->get('id')->getValue();
}
if (empty($teamid)) {
return null;
}
return $this->teamRepo->find($teamid);
}
public function getInputFilterSpecification()
{
return array(
'id' => array(
'required' => false,
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment