Then please pay attention to whether your include directory has been included, and your own directory that needs to be loaded
class Application_Form_Guestbook extends Zend_Form
{
public function init()
{
// Set the method for the display form to POST
$this->setMethod('post');//Set submission method
/ Definition of original type, noun, and some other information
'label' ('StringTrim'),
'validators' => array(
'EmailAddress',
)
));
// Add the comment element
$ this->addElement('textarea', 'comment', array(
'label' => 'Please Comment:',
'required' => true,
'validators' => ; array(
array('validator' => a captcha
$this->addElement('captcha', 'captcha', array(
'label' => 'Please enter the 5 letters displayed below:',
'required' => ; true,
'captcha' => array(
'captcha' => 'Figlet',
'wordLen' => 5,
'timeout' => 300
)
); ,
'Sign Guestbook', csrf', array(
'ignore' => true,
)); controller/GuestbookController.php
Copy code
The code is as follows:
class GuestbookController extends Zend_Controller_Action
{
// snipping indexAction()...
public function signAction()
{
$request = $this->getRequest(); //Get the received information
// include_once("../application/forms/Guestbook.php"); Manually load the class, only when it cannot be loaded automatically. Need
$form = new Application_Form_Guestbook;//Instantiate this method
if ($this->getRequest()->isPost()) {//If it is the result of POST delivery
mapper = new Application_Model_GuestbookMapper();
$mapper->save($comment);
return $this->_helper->redirector('index');
}
}
$this->view->form = $form;//Assign the form to the view
}
}
Finally add a simple The sign view file can be:
Address: application/views/scripts/guestbook/sgin.php
Copy code The code is as follows:
Please use the form below to sign our guestbook!
$this->form->setAction($this->url());
echo $this->form;
http://www.bkjia.com/PHPjc/327948.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327948.htmlTechArticle1. First, let us set up our program so that Zend can automatically load methods without us manually To load the copied code, the code is as follows: require_once 'Zend/Loader/Autoloader.p...