Have been trying to make this work for about an hour so far, im currently using cakephp 2 and everything is working perfect except this code
Here follows what I have inside User model
var $actsAs = array('Acl' => array('type' => 'requester'));
public function bindNode($user)
{
# ativando o simplified node mode
# trabalharemos apenas com permissões referentes ao grupo e não a cada usuário
#
return array('model' => 'Grupo', 'foreign_key' => $user['User']['grupo_id']);
}
public function parentNode() # utilizado para determinar um relacionmamento Pai -> Filho
{
if (!$this->id && empty($this->data))
return null;
if (isset($this->data['User']['grupo_id']))
$groupId = $this->data['User']['grupo_id'];
else
$groupId = $this->field('grupo_id');
if (!$groupId)
return null;
else
return array('Grupo' => array('id' => $groupId));
}
public function afterSave( $created ) # depois que as infos deste usuario sao salvas
{
# Funcao para permitir atualizar os grupos dos usuarios
if (!$created)
{
$parent = $this->parentNode();
$parent = $this->node($parent);
$node = $this->node();
$aro = $node[0];
$aro['Aro']['parent_id'] = $parent[0]['Aro']['id'];
$this->Aro->save($aro);
}
}
Basicaly he do everything just fine, update the table User with the correct group_id and if I use debug($aro) I can see it is trying to update with the correct information.
However the $this->Aro->save($aro) doens´t seem to work, also Cake dont show any error msg whatsoever, tryed several ways of debugging but no error is shown, it simply doesnt update the aro table.
ANyone have any idea why this is hapenning?
PS.: the Grupo instead of Group and grupo_id instead of group_id is also correct on the tables, its just a translation from English to Portuguese on those 2 cases only.