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_idgroup_by选项。

于 2012-04-29T17:12:23.477 回答