Last active
December 15, 2015 18:39
-
-
Save benglass/5305191 to your computer and use it in GitHub Desktop.
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 VDW\VTFABundle\Entity; | |
/** | |
* VDW\VTFABundle\Entity\Goal | |
* | |
* @ORM\Table(name="goal",indexes={@ORM\Index(name="name", columns={"name"})}) | |
* @ORM\Entity | |
*/ | |
class Goal | |
{ | |
/** | |
* @ORM\ManyToMany(targetEntity="Category", inversedBy="goals", cascade={"persist"}) | |
* @ORM\JoinTable(name="goal_category", | |
* joinColumns={@ORM\JoinColumn(name="goal_id", referencedColumnName="id")}, | |
* inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")} | |
* ) | |
*/ | |
private $categories; | |
/** | |
* Constructor | |
*/ | |
public function __construct() | |
{ | |
$this->categories = new \Doctrine\Common\Collections\ArrayCollection(); | |
} | |
/** | |
* Add category | |
* | |
* @param \VDW\VTFABundle\Entity\Category $category | |
* @return Goal | |
*/ | |
public function addCategory(\VDW\VTFABundle\Entity\Category $category) | |
{ | |
$this->categories[] = $category; | |
$category->addGoal($this); | |
return $this; | |
} | |
/** | |
* Remove category | |
* | |
* @param \VDW\VTFABundle\Entity\Category $category | |
*/ | |
public function removeCategory(\VDW\VTFABundle\Entity\Category $category) | |
{ | |
$this->categories->removeElement($category); | |
$category->removeGoal($this); | |
} | |
/** | |
* Get categories | |
* | |
* @return \Doctrine\Common\Collections\Collection | |
*/ | |
public function getCategories() | |
{ | |
return $this->categories; | |
} | |
} | |
public function buildForm(FormBuilderInterface $builder, array $options) | |
{ | |
$builder | |
->add('categories', 'genemu_jqueryselect2_entity', array( | |
'class' => 'VDWVTFABundle:Category', | |
'multiple' => true, | |
'empty_value' => '', | |
'help_inline' => 'Start typing to see categories', | |
'property' => 'name', | |
'attr' => array( | |
'class' => 'input-xxlarge' | |
) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment