Hello community
First of all sorry for my bad english. I got some problem I don't know how to send value from controller to controller I have 2 controller that handle 2 tables in database this is CustomerController and some code from my application.
class CustomerController extends ControllerBase {
public function createAction() {
if (!$this->request->isPost()) {
return $this->dispatcher->forward(array(
"controller" => "customer",
"action" => "index",
));
}
$customer = new Customer();
$onu = new Onu();
$customer->cus_fname = $this->request->getPost("cus_fname");
$customer->cus_lname = $this->request->getPost("cus_lname");
$customer->cus_addr = $this->request->getPost("cus_addr");
$customer->cus_tel = $this->request->getPost("cus_tel");
$customer->cus_circuit_no = $this->request->getPost("cus_circuit_no");
$customer->cus_fdf = $this->request->getPost("cus_fdf");
$customer->cus_sdp = $this->request->getPost("cus_sdp");
$customer->cus_odp = $this->request->getPost("cus_odp");
$customer->gpon_id = $this->request->getPost("gpon_id");
if (!$customer->save()) {
foreach ($customer->getMessages() as $message) {
$this->flash->error($message);
}
return $this->dispatcher->forward(array(
"controller" => "customer",
"action" => "test",
));
}
$this->dispatcher->forward(array(
"controller" => "onu",
"action" => "savecustomer",
"params" => array(
'onu_type' => $this->request->getPost("onu_type"),
'onu_mac' => $this->request->getPost("onu_mac"),
'cus_circuit_no' => $this->request->getPost("cus_circuit_no"),
'pon_id' => $this->request->getPost("gpon_id"),
)
)
);
$this->flash->success("customer was created successfully");
return $this->dispatcher->forward(array(
"controller" => "customer",
"action" => "test",
));
}
I want to send value from createAction In CustomerController to savecustomerAction in OnuController
class OnuController extends ControllerBase {
public function savecustomerAction($params = array()) {
$onu = new Onu();
$onu_type = $params['onu_type'];
$onu_mac = $params['onu_mac'];
$cus_circuit_no = $params['cus_circuit_no'];
$pon_id = $params['pon_id'];
if (!$onu->save()) {
foreach ($onu->getMessages() as $message) {
$this->flash->error($message);
}
}
I want to save it to my database too. Please explain how to save it and how to pass value . thank you so much