您好我是Zend Framework的新手, 我对Zend控制器有疑问,这是在一个视图页面中点击超链接的时候。该视图页面将一些参数传递给javascript,JavaScript执行一些表单操作并发布到控制器中, 该控制器调用另一个视图页面。但是我无法将价值传递给查看页面,任何人都可以帮我解决这个问题。
我的代码如下,
这是我的JavaScript
function getUserInfo(user_id, date)
{
//window.location.href= base_url+"/timemanagement/emptimesheets/employeeactivity";
// var locationUrl1= base_url+"/timemanagement/emptimesheets/employeeactivity.phtml";
// window.location.href = locationUrl1;
var form = document.createElement("form");
var ele_user_id = document.createElement("input");
var sel_date = document.createElement("input");
form.method = "POST";
//form.action = base_url+"/timemanagement/empact";
form.action = base_url+"/timemanagement/emptimesheets/employeeactivity";
sel_date.value=date;
sel_date.name="date";
form.appendChild(sel_date);
ele_user_id.value=user_id;
ele_user_id.name="user_id";
form.appendChild(ele_user_id);
document.body.appendChild(form);
form.submit();
}

public function employeeactivityAction()
{
try{
$clientsForm = new Timemanagement_Form_empact();
$empModel = new Timemanagement_Model_empact();
$user_id=$this->_request->getParam('user_id');
$sel_date=$this->_request->getParam('sel_date');
$this->view->ermsg = '';
$this->view->myVar = 1234;
// if($user_id > 0){
// $clientsForm->view->myVar = 167;//$user_id;
// $clientsForm->view->ermsg = 'now';
// error_log($user_id);
// }
error_log($user_id);
$sel_date=$this->view->date;
$this->view->form = $clientsForm;
$this->view->inpage = 'Add';
//$this->view->assign('user_id', $user_id);
}
catch(Exception $e)
{
$this->view->ermsg = 'nodata';
}
if($this->getRequest()->getPost()){
if($clientsForm->isValid($this->_request->getPost())){
$type_Entry =$this->_request->getParam('type_Of_Entry');
$level_Intensity=$this->_request->getParam('level_Of_Intensity');
$description = $this->_request->getParam('description');
// $user_id =$this->_request->getParam('user_id');
$date = new Zend_Date();
$data = array('emp_id'=>25,
'type_of_entry'=>$type_Entry,
'level_of_intensity'=>$level_Intensity,
'activity_desc'=>trim($description),
'date'=>$date
);

答案 0 :(得分:0)
i don't know if i get it, but If you do:
<?php echo $this->myVar ?>
on the view, you will print the data, but you can't send data to separated javascript files, unless you set an session, but its not the case.
can you give some more details?