2014-01-07 67 views
2

我想建立在我的奏鳴曲管理形式的多選標籤,如在picturebelow:複選標記奏鳴曲管理形式

http://i.stack.imgur.com/FUjRV.jpg

這裏是我的實體的代碼:

class Company{ 

    /** 
    * @ORM\Id 
    * @ORM\Column(type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    protected $id; 

    /** 
    * @ORM\Column(name="name", type="string", length=255) 
    */ 
    protected $name; 


    /** 
    * @ORM\ManyToMany(targetEntity="City", cascade={"persist"}) 
    */ 
    protected $city; 




    /** 
    * Constructor 
    */ 
    public function __construct() 
    { 
     $this->city = new \Doctrine\Common\Collections\ArrayCollection(); 
    } 

    /** 
    * Get id 
    * 
    * @return integer 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 


    /** 
    * Add city 
    * 
    * @param \Company\AdminBundle\Entity\City $city 
    * @return Company 
    */ 
    public function addVille(\Company\AdminBundle\Entity\City $city) 
    { 
     $this->city[] = $city; 

     return $this; 
    } 

    /** 
    * Remove city 
    * 
    * @param \Company\AdminBundle\Entity\City $city 
    */ 
    public function removeCity(\Company\AdminBundle\Entity\City $city) 
    { 
     $this->city->removeElement($city); 
    } 

    /** 
    * Get city 
    * 
    * @return \Doctrine\Common\Collections\Collection 
    */ 
    public function getCity() 
    { 
     return $this->city; 
    } 

    /** 
    * Set name 
    * 
    * @param string $name 
    * @return Company 
    */ 
    public function setName($name) 
    { 
     $this->name= $name; 

     return $this; 
    } 

    /** 
    * Get name 
    * 
    * @return string 
    */ 
    public function getName() 
    { 
     return $this->name; 
    } 

    public function __toString() 
    { 

     return (string) $this->name; 
    } 
} 

所以我希望第一個選擇標籤包含所有城市,第二個選擇我想要的任何元素。

我該如何製作這種類型?

回答

相關問題