Question

I started writing my first Zend Framework 2.0 (beta 1) PHP application using php 5.3.

I actually created a skeleton project and module based on the following url: http://packages.zendframework.com/docs/latest/manual/en/zend.mvc.quick-start.html

I want to add forms to the module I created. the my question is how do I configure the module to know where to fetch the forms in?

my module name is called LoginModule and I created a new form called LoginForm (that extends Zend_Form) and I placed it in my_proj/module/LoginModule/src/LoginModule/forms

how do I configure that module to know where to fetch the form class from ?

thanks

Was it helpful?

Solution

found the answer at http://akrabat.com/getting-started-with-zend-framework-2/

Everything has changed... (got better) in zend framework 2.

I created a directory called 'Form' in the src directory of my module. inside I create the class that extends Form (not Zend_Form) example from the tutorial above:

<?php
namespace Album\Form;
use Zend\Form\Form,
Zend\Form\Element;
class AlbumForm extends Form 
{
public function init()
{
    $this->setName('album');
    $id = new Element\Hidden('id');
    $id->addFilter('Int');
$artist = new Element\Text('artist');
$artist->setLabel('Artist')
           ->setRequired(true)
           ->addFilter('StripTags')
           ->addFilter('StringTrim')
           ->addValidator('NotEmpty');
    $title = new Element\Text('title');
    $title->setLabel('Title')
          ->setRequired(true)
          ->addFilter('StripTags')
          ->addFilter('StringTrim')
          ->addValidator('NotEmpty');
    $submit = new Element\Submit('submit');
    $submit->setAttrib('id', 'submitbutton');
    $this->addElements(array($id, $artist, $title, $submit));
 }
}

i really recommend reading the tutorial for all zend framework 2 beginner :)

thanks!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top