2012-04-29 2 views
0

をレンダリング:sfWidgetFormDoctrineChoiceGrouped私categorieテーブル用

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に追加しました:私は

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

Categoire with no parent 2 
    - child categroie 
    - child categorie.. 
を持つようにしたいレンダリングで

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

しかし私の場合はレンダリングがあります:

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がをグループ化するために使用する関係の名前でなければなりません。 group_byオプションにはparent_idを使用することもできます。

+0

解決策が見つかりましたが、今はtheresが最善ではありません。このようにwidgetClassを修正しました。 – Amine

+0

[私の答えを受け入れる](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)できますか? – j0k

関連する問題