【发布时间】:2016-03-05 13:57:35
【问题描述】:
控制器:
public function searchAction()
{
$form = new Application_Form_Search;
$k = $form->getValue('keyword');
$car = new Application_Model_Car();
$mapper = new Application_Model_CarMapper();
$this->view->cars = $mapper->search($keyword);
}
表格
<?php
class Application_Form_Search extends Zend_Form {
public function init(){
$this->setMethod('post');
$this->addElement('text', 'keyword', array(
'required' => true,
'label' => 'Keyword:'
));
$this->addElement('button', 'submit', array(
'required' => false,
'ignore' => true,
'label' => 'Search'
));
}
}
?>
原始视图页面
$(document).ready(function(){
$("#submit").click(function(){
$("#main").load('/cars/search');
});
});
这里我尝试使用.load()在原始视图页面的“id=main”部分返回搜索视图
在搜索视图中,<?=$this->keyword?> 显示为 null
从表单中获取关键字字段似乎有问题
【问题讨论】:
标签: ajax zend-framework zend-form