Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to select a value in dropdown in symfony2.0
    primarykey
    data
    text
    <p>How to select a value in drop down?</p> <h2>I have a drop down, when I was fill a drop down in edit case then how will to show the selected value from a database?</h2> <p>It is form builder class </p> <pre><code> public function buildForm(FormBuilder $builder, array $options) { $builder -&gt;add('name') -&gt;add('description') -&gt;add('parentid', 'entity', array('class'=&gt;'MusicCoreBundle:MusicCategory', 'property' =&gt; 'name', 'required' =&gt; false, 'query_builder' =&gt; function(EntityRepository $er) {return $er-&gt;createQueryBuilder('s')-&gt;orderBy('s.name', 'ASC');}, 'empty_value' =&gt; 'No category')); } </code></pre> <p>This is using for ER,i think the entity relation with id and parentid is wrong ,please reply with code, In entity declaration:</p> <pre><code> /** * Music\Bundles\Core\Entity\MusicCategory * @ORM\Table(name="ms_musiccategory") * @ORM\Entity() * @ORM\Entity(repositoryClass="Music\Bundles\Core\Entity\Repository\CategoryRepository") * @UniqueEntity(fields={"name"},message="The name is already in this system.") */ class MusicCategory { /** * @ORM\Column(name="id",type="integer") * @ORM\Id() * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** *@ORM\ManyToOne(targetEntity="MusicCategory") *@ORM\JoinColumn(name="parent_Id", referencedColumnName="id") * */ private $parentid; /** * @ORM\Column(name="name", type="string", length=50, unique=true) */ private $name; /** * @ORM\Column(name="description", type="string", length=200) */ private $description; public function __construct() { } /** * @see RoleInterface */ public function getName() { return $this-&gt;name; } /** * Get id * * @return integer */ public function getId() { return $this-&gt;id; } /** * Set id * * @return integer */ public function setId($id) { $this-&gt;id = $id; } /** * Get parentid * * @return integer */ public function getParentId() { return $this-&gt;parentid; } /** * Get parentid * * @return integer */ public function setParentId($parentid) { $this-&gt;parentid = $parentid; } /** * Set role * * @param string $role */ public function setName($name) { $this-&gt;name = $name; } /** * Set description * * @param string $description */ public function setDescription($description) { $this-&gt;description = $description; } /** * Get description * * @return string */ public function getDescription() { return $this-&gt;description; } } </code></pre> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload