필드 (이름, 요약) 제출 단추가있는보기 (_form.php)가 있습니다. 제출 버튼을 클릭하면 다른 모델의 한 모델과 요약 필드의 이름 필드가 업데이트됩니다. 두 모델 모두 다른 데이터베이스입니다. 누구든지이 문제를 해결할 수 있습니까? 나는 TestController.phpyii의 단일보기로 다른 데이터베이스의 두 모델 업데이트
에서 _form.php (테스트)<?php echo $form->labelEx($model, ‘name’); ?>
<?php echo $form->textField($model, ‘name’, array(‘size’ => 60, ‘maxlength’ => 250)); ?>
<?php echo $form->error($model, ‘name’); ?>
<?php echo $form->labelEx(Test1::model(), ‘summary’); ?>
<?php echo $form->textField(Test1::model(), ‘summary’, array(‘size’ => 60, ‘maxlength’ => 250)); ?>
<?php echo $form->error(Test1::model(), ‘summary’); ?>
<?php echo CHtml::submitButton($model->isNewRecord ? ‘Create’ : ‘Save’); ?>
에서이 코드가 작동하지 않는
public function actionCreate() {
$model = new Test;
if (isset($_POST['Test'])) {
$model->attributes = $_POST['Test'];
if ($model->save()) {
$modeltest1 = new Test1;
$modeltest1->attributes = $_POST['Test1'];
$modeltest1->Id = $model->Id;
if ($modeltest1->save())
$this->redirect(array('view', 'Id' => $model->Id));
}
}
$this->render('create', array(
'model' => $model,
));
}
을이
에 대해 다음을 시도했다. 다른 데이터베이스에서 어떻게 작동하게 할 수 있습니까? 나는 이것을 위해 아래 링크를 따라 갔다.
http://www.yiiframework.com/wiki/291/update-two-models-with-one-view/
고맙습니다 ... 대단히. 나는 PHP와 Yii에 익숙하지 않습니다. – Rudra