2010-08-10 104 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