tags:

views:

42

answers:

0

Hi,

I have a table structure like this

admins table habtm rights table belongs to rights_groups

In view I need to print like this as checkbox

Rights_group Name1
    Rights1
    Rights2
Rights_group Name2
    Rights3
    Rights4

View code (Since I have to give the group name, I need to loop through the records)

$checked = $form->value('Right.Right');
foreach ($rights as $id => $item) {
        // Here Im printing the group name with some condition
        echo $form->input("Right.checked." . $item['Right']['id'],
array(
                                'label'=> $item['Right']['name'],
                                'type'=>'checkbox',
                                'checked'=>(isset($checked[$item
['Right']['id']])?'checked':false),
                        ));

}

All these are working fine, but it is not saving the records in the join table. I have given only $this->Admin->save($this->data) in controller. If I give in the following way, it is working (but I need to show the group name in between)...

echo $form->input('right', array('div' => false, 'label' => false,
'class' => 'otherforms', 'type' => 'select', 'multiple' =>
'checkbox'));

Any help ?