sfWidgetFormDoctrineChoiceGrouped render

287 Views Asked by At

for my categorie table:

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}

i've add to my form a sfWidgetFormDoctrineChoiceGrouped with this configuration:

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

In the render i want to have

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

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

but in my case i have a render with:

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

Thank you

1

There are 1 best solutions below

1
On BEST ANSWER

There are some mistakes in your options:

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

group_by have to be The name of the relation to use for grouping. I think you can also use parent_id for the group_by option.