Cake PHP は初めてです。問題があります。
モデルには、Guardian、Student、StudentFee の 3 つがあります。
関係は次のようになります。Guardian hasMany Student 、Student hasMany StudentFee、StudentFee belongsTo Guardian、Student.
私の問題は、学生と保護者の詳細が挿入される以外に、StudentFee の詳細が挿入されないことです。
私のモデルは
class Guardian extends AppModel {
public $name = 'Guardian';
public $recursive =2;
public $hasMany = array(
'Student' => array(
'className' => 'Student',
'dependent' => true
)
);
}
class Student extends AppModel {
public $name = 'Student';
public $hasMany = array(
'StudentFee' => array(
'className' => 'StudentFee',
'dependent' => true
)
);
}
class StudentFee extends AppModel {
public $name = 'StudentFee';
public $belongsTo = array(
'Guardian' => array(
'className' => 'Guardian',
'dependent' => true
),
'Student' => array(
'className' => 'Student',
'dependent' => true
)
);
}
私のコントローラーでは、以下のコードのように saveAssociated() を使用しました
$this->Guardian->set($this->request->data);
$this->Guardian->saveAssociated($this->Guardian->data, array('validate' => false));
この問題の解決にご協力ください。よろしくお願いします。