Where does Zend_Form fit in the Model View Controller paradigma

后端 未结 3 1507
独厮守ぢ
独厮守ぢ 2021-01-02 15:49

The Zend Framework is mainly meant for MVC use. One of the very usefull components is Zend_Form.

I have a bit trouble finding the place of Zend_Form. Is it part of t

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 16:13

    IMO, Zend_Form is designed to wear multiple hats. It is, in fact, a bridge between the view and model with a giant support beam from the controller.

    Instead of assigning a Form to a Model, consider assigning Model(s) to a form.

    In the Model layer, you can have a a getFormInputs method that could return the Elements needed to input data. The model doesn't care what form is going to use it, it just makes it available to any from that wants them.

    Now in your form layer, make a setupInputs method that will loop thru an array of models to grab all the inputs. If there was only one model, add the inputs to the form. If there was more then one model, make sub forms.

    Your controller will initiate the form and pass the values back to model (see Keyne's newAction method)

提交回复
热议问题