2012-04-29 3 views
0

для моей категории таблицы:sfWidgetFormDoctrineChoiceGrouped делают

Categorie: 
    actAs: 
    Timestampable: ~ 
    Sluggable: 
     fields: [nom] 
    NestedSet: ~ 
    columns: 
    parent_id: { type: integer(8), notnull: false} 
    nom:  { type: string(255), notnull: true, unique: true } 
    relations: 
    CategorieParent: { onDelete: SET NULL, local: parent_id, class: Categorie, foreign: id, foreignAlias: CategorieEnfants} 

я добавить к моему образуют sfWidgetFormDoctrineChoiceGrouped с такой конфигурацией:

'categorie'  => new sfWidgetFormDoctrineChoiceGrouped(
         array(
          'group_by' => 'parent', 
          'order_by' => array('parent_id',''), 
          'model' => 'Categorie', 
          'multiple' => true, 
          'method' => 'getNom', 
          )), 

В рендер я хочу иметь

Categoire with no parent 1 
    - child categroie 
    - child categorie.. 

Categoire with no parent 2 
    - child categroie 
    - child categorie.. 

, но в моем случае у меня есть рендер с:

Categoire with no parent 1 
Categoire with no parent 2 
Categoire with no parent 3 
Categoire with no parent 1 
    - child categroie 
    - child categorie.. 

Спасибо

ответ

0

Есть некоторые ошибки в параметрах:

'group_by' => 'CategorieParent', 
'order_by' => array('parent_id','ASC'), 

group_by должны быть Имя связи использовать для группировки. Я думаю, вы также можете использовать parent_id для опции group_by.

+0

ihave нашел решение, но я сейчас, theres не самый лучший, я изменил widgetClass вот так. – Amine

+0

вы могли бы [принять мой ответ] (http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)? – j0k