Created
May 22, 2012 15:11
-
-
Save tristanbes/2769672 to your computer and use it in GitHub Desktop.
The form's client data is expected to be of type scalar, but is an instance of class Doctrine\ORM\PersistentCollection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace GamerCertified\TeamBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* GamerCertified\TeamBundle\Entity\Conditions | |
* | |
* @ORM\Table(name="conditions") | |
* @ORM\Entity(repositoryClass="GamerCertified\TeamBundle\Entity\ConditionsRepository") | |
*/ | |
class Condition | |
{ | |
/** | |
* @var integer $id | |
* | |
* @ORM\Column(name="id", type="integer") | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="AUTO") | |
*/ | |
private $id; | |
/** | |
* @var string $name | |
* | |
* @ORM\Column(name="name", type="string", length=255) | |
*/ | |
private $name; | |
/** | |
* @var integer $team | |
* | |
* @ORM\ManyToOne(targetEntity="GamerCertified\TeamBundle\Entity\Team", inversedBy="conditions") | |
*/ | |
private $team; | |
/** | |
* Get id | |
* | |
* @return integer | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* Set name | |
* | |
* @param string $name | |
* | |
* @return Conditions | |
*/ | |
public function setName($name) | |
{ | |
$this->name = $name; | |
return $this; | |
} | |
/** | |
* Get name | |
* | |
* @return string | |
*/ | |
public function getName() | |
{ | |
return $this->name; | |
} | |
/** | |
* Set team | |
* | |
* @param integer $team | |
* | |
* @return Conditions | |
*/ | |
public function setTeam($team) | |
{ | |
$this->team = $team; | |
return $this; | |
} | |
/** | |
* Get team | |
* | |
* @return integer | |
*/ | |
public function getTeam() | |
{ | |
return $this->team; | |
} | |
public function __toString() | |
{ | |
return (string) $this->getName(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace GamerCertified\TeamBundle\Form\Type\Team; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilder; | |
class ConditionType extends AbstractType | |
{ | |
public function buildForm(FormBuilder $builder, array $options) | |
{ | |
$builder->add('name'); | |
} | |
public function getName() | |
{ | |
return 'condition'; | |
} | |
public function getDefaultOptions() | |
{ | |
return array('data_class' => 'GamerCertified\TeamBundle\Entity\Condition'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace GamerCertified\RecruitmentBundle\Form\Type; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilder; | |
class LinkForm extends AbstractType | |
{ | |
public function buildForm(FormBuilder $builder, array $options) | |
{ | |
$builder->add('url', null, array()); | |
$builder->add('type', 'entity' , array( | |
'class' => 'GamerCertified\RecruitmentBundle\Entity\LinkType', | |
'multiple' => false, | |
'expanded' => false, | |
)); | |
} | |
public function getDefaultOptions() | |
{ | |
return array('data_class' => 'GamerCertified\RecruitmentBundle\Entity\Link'); | |
} | |
public function getName() | |
{ | |
return 'link_create'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace GamerCertified\TeamBundle\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use GamerCertified\UserBundle\Entity\User; | |
use GamerCertified\GameBundle\Entity\Game; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Gedmo\Mapping\Annotation as Gedmo; | |
use Symfony\Component\Validator\Constraints as Assert; | |
/** | |
* GamerCertified\TeamBundle\Entity\Team | |
* @ORM\Table(name="team") | |
* @ORM\Entity(repositoryClass="GamerCertified\TeamBundle\Entity\TeamRepository") | |
* | |
*/ | |
class Team | |
{ | |
/** | |
* @ORM\OneToMany(targetEntity="GamerCertified\TeamBundle\Entity\Condition", mappedBy="team", cascade={"all"}, orphanRemoval=true) | |
*/ | |
private $conditions; | |
/** | |
* @ORM\OneToMany(targetEntity="GamerCertified\RecruitmentBundle\Entity\Link", mappedBy="team", cascade={"all"}, orphanRemoval=true) | |
*/ | |
private $links; | |
public function __construct($user) | |
{ | |
$this->creator = $user; | |
$this->links = new ArrayCollection; | |
$this->conditions = new ArrayCollection; | |
} | |
public function setLinks($links) | |
{ | |
$this->links = $links; | |
} | |
public function getLinks() | |
{ | |
return $this->links; | |
} | |
public function addLink($link) | |
{ | |
$this->links->add($link); | |
} | |
public function removeLink($object) | |
{ | |
$this->links->remove($object); | |
} | |
public function setConditions($conditions) | |
{ | |
$this->conditions = $conditions; | |
} | |
public function getConditions() | |
{ | |
return $this->conditions; | |
} | |
public function addCondition($condition) | |
{ | |
$this->conditions->add($condition); | |
} | |
public function removeCondition($object) | |
{ | |
$this->conditions->remove($object); | |
} | |
public function __toString() | |
{ | |
return $this->getSlug(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace GamerCertified\TeamBundle\Form\Type; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilder; | |
use GamerCertified\TeamBundle\Form\Type\Team\ConditionType; | |
use GamerCertified\RecruitmentBundle\Form\Type\LinkForm; | |
class TeamType extends AbstractType | |
{ | |
public function buildForm(FormBuilder $builder, array $options) | |
{ | |
$builder->add('conditions', 'collection', array( | |
'type' => new ConditionType(), | |
'allow_add' => true, | |
'single_control' => false, | |
'allow_delete' => true, | |
'show_legend' => false, | |
'prototype' => true, | |
'options' => array( | |
'data_class' => 'GamerCertified\TeamBundle\Entity\Condition', | |
'label_render' => false, | |
'required' => false, | |
'widget_control_group' => false, | |
'attr' => array('class' => 'span3'), | |
) | |
)); | |
$builder->add('links', 'collection', array( | |
'type' => new LinkForm, | |
'single_control' => false, | |
'allow_add' => true, | |
'show_legend' => false, | |
'allow_delete' => true, // should render default button, change text with widget_remove_btn | |
'prototype' => true, | |
'options' => array( // options for collection fields | |
'data_class' => 'GamerCertified\RecruitmentBundle\Entity\Link', | |
'required' => false, | |
'label_render' => false, | |
'widget_control_group' => false, | |
'attr' => array('class' => 'span3') | |
) | |
)); | |
} | |
public function getDefaultOptions() | |
{ | |
return array( | |
'data_class' => 'GamerCertified\TeamBundle\Entity\Team', | |
); | |
} | |
public function getName() | |
{ | |
return 'team_edit'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment