Skip to content

Instantly share code, notes, and snippets.

@benglass
Last active December 15, 2015 18:39
Show Gist options
  • Save benglass/5305191 to your computer and use it in GitHub Desktop.
Save benglass/5305191 to your computer and use it in GitHub Desktop.
<?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