I am new to Zend framework and have just started working on it. I am going to create a simple webpage accepting the username and password and then after authentication go to another webpage.
This is my reqirement in layman’s terms. For that, according to my understanding, the following structure should be used for Zend Framework:
- LoginController:contains
loginAction() - Application_Login_Form:that contains the textfield for username and password.
- login.phtml
Now execution starts from loginAction(). In loginAction() I call the Application_Login_Form and authenticate the given credentials then call login.phtml using $view->render('login.phtml');.
My First question is; Is that the right flow in Zend Framework or there should be some difference?
My Second question is; When I use Application_Login_Form extends Zend_Form I want to use <div id='ex'> because i want to use a css file and in which I have defined the style for div id ‘ex’. Can I use that div in Application_Login_Form? And If yes, then How? And if no then What should be done?
I might be able to help with the second question.
I use view scripts to get the format I want for all of my form models.
So in application/models/FormLogin.php I would set up the Zend_Form elements I want then define the view script like this:
then in application/views/scripts/_form_login.phtml I define the view:
If you use your own label tags like this make sure you remove them from the form element in FormLogin.php:
I also get rid of the default htmltags:
If you want a good how-to book for learning Zend I would recommend Easy PHP Websites with the Zend Framework by W Jason Gilmore. It really helped me. I did have a tough part in the first few chapters getting the framework set up and working properly, but after that it was easy to catch on. Good luck.