1

I'm stuck with something fairly simple:
SN hasMany NA. I retrieve data, with a condition on the contained NAs using

 $this->find('all',array(
        'recursive' => -1,
        'conditions' => array(
            'SN.deleted IS NULL',
            'SN.user_id' => $user_id,
            ),
        'contain' => array(
            'NA' => array('conditions'=> array('wave' => 1) ),
        )
    ));

Both SN and NA act as Containable.

I get the data, but NA is not nested in the SN array:

array(
  (int) 0 => array(
    'SN' => array(
        'id' => '1',
        'user_id' => '1',
    ),
    'NA' => array(
        (int) 0 => array(
            'id' => '1',
            'SN_id' => '1',
            'wave' => '1',
        )
    )
),

This results in a lot of annoying behaviour using the FormHelper (which I fix at the moment by massaging the data for my needs, but I'd still like to understand what I am doing wrong), e.g. with the data returned from Containable, I can't specify the path.

debug($this->data[$s]['NA'][0]['wave']); # would work
echo $this->Form->input("$s.NA.0.role"); # doesn't work
# leads to data[SN][0][NA][0][role] # SN is auto-prepended
echo $this->Form->input("$s.SA.NA.0.role"); # what I use after massaging the data so it's nested

I still have problems with validation messages not showing up where they're supposed, even though I tried both massaging the data and the error message arrays.

Ruben
  • 3,452
  • 31
  • 47

0 Answers0