Amigos preciso de uma ajuda. Estou fazendo um cadastro de cliente. Meu form de cliente carrega os campos do modelo telefone, preciso que logo após salvar os dados do cliente salve o telefone na tabela telefone. Estou fazendo assim:
public function actionCreate() {
$model = new Cliente;
$telefone = new Telefone;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Cliente']) && isset($_POST['Telefone'])) {
$model->attributes = $_POST['Cliente'];
$telefone->attributes = $_POST['Telefone'];
if ($model->save())
$telefone->save();
$this->redirect(array('view', 'id' => $model->idcliente));
}
$this->render('create', array(
'model' => $model,
));
}