Submitting your form to another presenter

You probably know that you can define your form as a component in a class of its own and handle its submission in the same class. This is handy if the submission handling logic can be isolated and is independent of any presenter. But what if it needs to be a part of some particular presenter lifecycle? Then you need to force the form to submit to this particular presenter.

Define your form as a component (e.g. app/forms/SignInForm.php):

  1. span class=”st0″>’name’, ‘Name:’);
  2.     // …
  3.     $this->addSubmit(‘login’, ‘Sign In’);
  4.   }
  5. }
  6.  

Handle the submission in the target presenter (app/presenters/MainPresenter.php):

  1. span class=”st0″>’signInFormSubmitted’// …
  2. }
  3.  

For the other presenters, you’ll need to use a bit of a hacky solution (app/presenters/OtherPresenter.php):

  1. span class=”co1″>// it’s okay to change your form here
  2. ‘login’]->caption = ‘Continue’‘Main:myAction’‘submit’

Tags:

Leave a Reply