2010-08-10 109 views

回答

2

您可以使用普通的HTML表单。为您的控制器部分的代码片段:

// Get all params (Notice: including URL params) 
$this->getRequest()->getParams(); 

// Get single param 
$this->getRequest()->getParam('paramName'); 

// Check if post 
$this->getRequest()->isPost(); 
1

请参阅

+0

我不想使用zend_form,但我希望使用简单的html表单。如何做到这一点 – 2010-08-10 09:27:21

+0

@Ankhur为什么不简单地输出一些形式的HTML呢?你需要什么Zend Framework? – 2010-08-10 09:28:18

+0

没有使用zend形式的手段,你说它会有点不正确地使用zend框架,实际上是在浪费它 – 2010-08-10 09:35:04

1

只需创建您的形式,就像您正常,但在你的视图文件(index.phtml例如)。 它会工作。没什么特别的,只需打开一个<form>标签并开始编码即可。

+0

投票响应确切地要求什么 – 2011-06-10 14:35:00

0

如果你真的想用简单的HTML表单,你至少应该考虑Zend_Filter_Input过滤/验证userinput。

$filters = array('body' => array('StringTrim' , 'StripTags')); 
$validators = array('body' => 'Alpha'); 

if (!$this->getRequest()->isPost()) { 
    // display form; 
    return; 
} 

$input = new Zend_Filter_Input($filters, $validators, $this->getRequest()->getParams()); 

if (!$input->isValid()) { 
    // failed validation 
    $this->view->messages = $input->getMessages(); 
    // redisplay form and show error messages 
    return; 
} 

// form is valid, values are filtered 
echo $input->body