컨트롤러 1의 기능 (동작)에서 숨겨진 데이터를 컨트롤러 2의 기능 (동작)으로 보내는 방법을 모르겠습니다.숨겨진 데이터를 Yii의 다른 컨트롤러로 보내는 방법
POST로 두 번째 기능에 데이터를 보내는 것이 좋다고 생각합니다. 양식을 사용하지 않고 POST 데이터 노하우를 보내려고하지 않습니다.
도와 주시겠습니까? 내 영어
Controller1에 대한
죄송합니다 :
클래스 DeviceController이 컨트롤러를 확장 {
public function actionDeviceTurnOn(){ if(isset($_GET['id_device'])){ $id_device = $_GET['id_device']; $model = $this->loadModel($id_device); $model->status = 1; $title = "Message of admin"; $message = "Good morning" . "\r\n" . "\r\n" . "The device is On"; MessagesController::messageAutoComplete(Yii::app()->user->id, $_GET['id_user'], $title, $message); } } } ?>
컨트롤러 2 :
클래스 MessagesController exte NDS 컨트롤러 {
public function messageAutoComplete($from_user_id=null, $to_user_id=null, $title=null, $message=null){ $data['from_user_id'] = $from_user_id; $data['to_user_id'] = $to_user_id; $data['title'] = $title; $data['message'] = $message; MessagesController::actionCompose($data); } public function actionCompose ($data=null) { $model=new Messages; $this->performAjaxValidation($model); if(isset($_POST['Messages'])) { foreach($_POST['Messages']['to_user_id'] as $user_id) { $model = new Messages; $model->attributes=$_POST['Messages']; $model->to_user_id = $user_id; $model->save(); } $this->redirect(array('success')); } $model->to_user_id = ""; if($data != null){ $model->from_user_id = $data['from_user_id']; $model->to_user_id = $data['to_user_id']; $model->title = $data['title']; $model->message = $data['message']; } $this->render('compose',array( 'model'=>$model, )); } }
이 내가 할 것이지만, 그것이 작동하지 않을 것입니다!
몇 가지 코드 예를 들려 줄 수 있습니까? –
무엇을 하시겠습니까? 왜 다른 컨트롤러로 데이터를 보내고 싶습니까? – Sergey
작동하지 않는 기능은 무엇입니까? 컨트롤러 2에서 actionCompose를 호출 할 때 $ data에 아무것도 없다는 것을 알고 있습니까? – ernie