views:

39

answers:

4

It is possible to make form and table (View) by both using zend_form with decorators, validators , filters etc, and we can also do this directly in view phtml file writing html as usual. I want to know which one is the best way to do in terms of

  1. Performance
  2. Time
  3. Simplicity

I am new to zend framework.

+1  A: 

Look at the following article. It contains almost everything related to Zend Form like validators, decorators and access methods:

Creating Forms Using Zend_Form

NAVEED
A: 

The best way is described in the docs. Don't write it at hand. Even considering the eventual possibility of it being faster it's something you don't want to do at all: Hardware is cheap. Labor is not.

And now imagine you've to get from the floor A to B, C, D... If you use the elevator every time you're less prone to errors (giving that the elevator is a box you just come in, press a single button, travel during some time on it and then come out) than if you use the stairs (you've to lift your feet different ways to go up/down, have to check every single step you do as well as every single stair (maybe there's water leaking from the floor), etc).

  • doing exercise is not the point.

See Keep it simple, Stupid!

Henrique Vicente
I have asked this question to clear my doubts. But u r making me more confused.
seed_of_tree
Sorry. Let's try now: the better way to make forms using the Zend Framework is described in its documentation. Writing the HTML forms by yourself is a waste of time.
Henrique Vicente
+1  A: 

I think that using forms in view script is the best way, because:

  1. It's more flexible way
  2. It's better for perfomance
  3. Other nonzend developer can understand your code

Excuse me for my English

DimaKrasun
Hi all is DimaKrasun is ok? I am aslo thinking so.
seed_of_tree
@DimaKrasun Flexible? So how do you dynamically remove element from the form? How do you combine the forms together? How do you change markup from `dl` to `div` for all forms? Zend developer == PHP Developer => he understands the oop php syntax
takeshin
+3  A: 

Performance

Can always be increased by caching, better machine.

Time

Just learn your IDE, it will code the forms for you (macros, shortcuts, templates etc.)

Simplicity

Zend From usage couldn't be simpler. You may even just create the form by writing plain text (ini syntax).


So, newer create forms in the view.


The best way:

// application/modules/search/forms/Search.php

class Search_Form_Search extends Application_Form_Abstract
{
    public function init()
    {
      $this->addElements(array(
          // other elements here
          new Zend_Form_Element_Submit('search_submit'),
      ));
    }
}

In the model:

// application/modules/search/models/Search.php

...
public function getForm()
{
    return new Search_Form_Search();
}
takeshin