phpzend-frameworkzend-formzend-framework-mvc

Show form of other controller


I'm new to Zend Framework 1 and I try to build a small blogsoftware (just to get into ZF1) and I've got following problem:

I want an user allow to comment an article of my site. Therefor I have two controller.
First one is the comment-controller with the action "create", the view "create" and the form "commentcreate".

The other controller is the article-controller with the action "showdetails" and the view "showdetails", where the user can see the whole article.

My question: Can I show the commentcreate-form on the showdetails-view? Or what is the right way to do something like that?
Hope someone can help me.


Solution

  • I would suggest you to go with following flow:

    Create articleControllerwith showdetailsAction and instantiate your commentcreate form inside showdetailsAction itself. Create its view with details of your article along with comment form.

    Create one more action inside articleController to add comment into the database which will be used when user will submit comment. For e.g. createCommentAction When user will fill comment form and will submit that form at that time make an ajax request to server and call createCommentAction to store values in database.

    Hope it is making sense.