0

私のカテゴリテーブルの場合:

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..

ありがとうございました

4

1 に答える 1

0

オプションにはいくつかの間違いがあります。

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

group_byグループ化に使用するリレーションの名前である必要があります。parent_idオプションにも使えると思いgroup_byます。

于 2012-04-29T17:12:23.477 に答える