Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It seems, that you are trying to manually create/update records for M:N relation. This isn't needed, because Dotrine ORM will create or delete these records in middle table for M:N relation automatically.</p> <ul> <li><p>Check, that you have correct relations in your database structure. You can visualize your database structure in some database modeling application, like <a href="https://www.mysql.com/products/workbench/" rel="nofollow">Mysql Workbench</a>.</p></li> <li><p>Map correctly your database structure to doctrine config files. Reverse engineering of your database may help: <a href="http://symfony.com/doc/current/cookbook/doctrine/reverse_engineering.html" rel="nofollow">http://symfony.com/doc/current/cookbook/doctrine/reverse_engineering.html</a> In doctrine config file "User.orm.xml" should be <em>many-to-many</em> relation. For example:</p></li> </ul> <pre><code> &lt;many-to-many field="cityId" target-entity="City" inversed-by="userId"&gt; &lt;join-table name="user_has_city"&gt; &lt;join-columns&gt; &lt;join-column name="id_user" referenced-column-name="id_user"/&gt; &lt;/join-columns&gt; &lt;inverse-join-columns&gt; &lt;join-column name="city_id" referenced-column-name="city_id"/&gt; &lt;/inverse-join-columns&gt; &lt;/join-table&gt; &lt;/many-to-many&gt; </code></pre> <ul> <li><p>Add __toString() method to your City entity:</p> <p> <pre><code>//...some code of entity... public function __toString() { return $this-&gt;name; //or $this-&gt;title, $this-&gt;label etc. - based on the name of variable, which stores the city's name. } </code></pre></li> <li><p>In file AcmeExampleBundle/Admin/UserAdmin.php:</p> <p> <pre><code>$formMapper -&gt;add('cityId', 'sonata_type_model', array( 'required' =&gt; false, 'label' =&gt; $this-&gt;trans('City name'), 'expanded' =&gt; true, )); </code></pre></li> </ul>
 

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