私のカテゴリテーブルの場合:
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..
ありがとうございました