0

Looking for some advice \ improvements on the structure of my application

user logs in and is presented with a welcome message and a menu of options each option points to the same controller e.g OptionController but with different actions

/option/abc
/option/def

OptionController.php { abcAction() defAction() } 

the reason why I have different actions is because each option will require a different form

when the form is rendered and the user enters input the request is submitted to a validate controller again with a different action per option. i need basic form validation + custom business logic

I have it "working" but don't think it's a good way to do it. Thoughts?

2
  • Are you asking if only having one controller with a lot of actions is bad? Commented Aug 14, 2009 at 11:18
  • No. It's more with the handling of the form. Should I have an action to render the form + an action to process the form in the same controller? If the validation fails I'd like to redisplay the form with appropriate validate error Commented Aug 14, 2009 at 11:23

1 Answer 1

2

I would recommend a structure where you summarize not the art (display, validated) of task, but the, in your words, "options"

for example (:

controller: abcController actions: addAction() editAction() listAction() viewAction() deleteAction() controller: defController actions: addAction() editAction() listAction() viewAction() deleteAction() 

the configs for your forms (including validation) should be in own classes extended from Zend_Form which are stored in its own folder. eg APPLICATION_PATH.'/forms'. (see ZF - autoloader) displaying and validating forms can reside in the same action, i usaly split them into add and edit. (but using the same form class for both)

task's you need in all controllers are best to be implemented as action or view helpers.

Sign up to request clarification or add additional context in comments.

1 Comment

maybe it would be better to split each option into its own controller. thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.