Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand your question correctly you would like to store associated school ids. Use the <code>sfWidgetFormDoctrineChoice</code> widget instead and it will work out of the box, as it using primary keys as ids.</p> <pre><code>$query = Doctrine_Core::getTable('school')-&gt;queryForSelect($userId); $this-&gt;setWidget('schools', new sfWidgetFormDoctrineChoice(array( 'model' =&gt; 'school', 'query' =&gt; $query, 'multiple' =&gt; true, 'renderer_class' =&gt; 'sfWidgetFormSelectDoubleList', 'renderer_options' =&gt; array( 'label_unassociated' =&gt; 'Unassociated', 'label_associated' =&gt; 'Associated' ), ))); $this-&gt;setValidator('schools', new sfValidatorDoctrineChoice(array( 'model' =&gt; 'schoool', 'query' =&gt; $query, 'multiple' =&gt; true, ))); // in SchoolTable class public function queryForSelect($userId) { return $this-&gt;createQuery('s') -&gt;andWhere('s.user_id = ?', $userId) ; } </code></pre> <p>If you has a proper schema (I presume the schools should be a many-to-many association), then the current from should has a <code>schools_list</code> field (properly defined in the generated base from) and then you can modify that field to be rendered by <code>sfWidgetFormSelectDoubleList</code>:</p> <pre><code>$this-&gt;widgetSchema['schools_list']-&gt;setOption('renderer_class', 'sfWidgetFormSelectDoubleList'); $this-&gt;widgetSchema['schools_list']-&gt;setOption('renderer_options', array( 'label_unassociated' =&gt; 'Unassociated', 'label_associated' =&gt; 'Associated' )); </code></pre>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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