Czytam dokumentacje ZendFramewoka i nie bradzo rozumiem gdzie mam powstawiać pewne moduły aby formularz działał prawidłowo.
Na stronie:
http://framework.zend.com/manual/en/zend.f...quickstart.html
jest cały opis.
Dokładnie chodzi mi o punkt. : 23.2.6. Putting it together
Nie wiem w które pliki powstawiać kod.
1.
----------------------------------------------------
<?php $form = new Zend_Form(); $form->setAction('/user/login') ->setMethod('post'); // Create and configure username element: $username = $form->createElement('text', 'username'); $username->addValidator('alnum') ->setRequired(true) ->addFilter('StringToLower'); // Create and configure password element: $password = $form->createElement('password', 'password'); ->setRequired(true); // Add elements to form: $form->addElement($username) ->addElement($password) // use addElement() as a factory to create 'Login' button: ?>
2. W controler
------------------------------------------------
<?php class UserController extends Zend_Controller_Action { public function getForm() { // create form as above return $form; } public function indexAction() { // render user/form.phtml $this->view->form = $this->getForm(); $this->render('form'); } public function loginAction() { if (!$this->getRequest()->isPost()) { return $this->_forward('index'); } $form = $this->getForm(); if (!$form->isValid($_POST)) { // Failed validation; redisplay form $this->view->form = $form; return $this->render('form'); } $values = $form->getValues(); // now try and authenticate.... } } ?>
3. w widok
---------------------------------------------
<h2>Please login:</h2>
Punk 2 i 3 to wiem, ale nie wiem gdzie 1.
Korzystam z Zend Studio. W momencie dodawanie Controlera tworzy mi się automatycznie widok.
Ale punkt 1 prawdopodobnie bo tak mi sie wydaje wstawia sie do View Helper. Ale jaki Helper's Prefix i Helper's Name ?
Przemek