Pass the current form instance to the callback as second argument

refs #5525
This commit is contained in:
Johannes Meyer 2014-09-01 14:58:16 +02:00
parent 0822aff293
commit cd8015f41a
1 changed files with 4 additions and 4 deletions

View File

@ -28,7 +28,7 @@ class Form extends Zend_Form
/** /**
* The callback to call instead of Form::onSuccess() * The callback to call instead of Form::onSuccess()
* *
* @var Closure * @var Callback
*/ */
protected $onSuccess; protected $onSuccess;
@ -79,8 +79,8 @@ class Form extends Zend_Form
/** /**
* Create a new form * Create a new form
* *
* Accepts an additional option `onSuccess' which is a * Accepts an additional option `onSuccess' which is a callback that is called instead of this
* callback that is called instead of this form's method. * form's method. It is called using the following signature: (Request $request, Form $form).
* *
* @see Zend_Form::__construct() * @see Zend_Form::__construct()
* *
@ -457,7 +457,7 @@ class Form extends Zend_Form
$this->populate($formData); // Necessary to get isSubmitted() to work $this->populate($formData); // Necessary to get isSubmitted() to work
if (! $this->getSubmitLabel() || $this->isSubmitted()) { if (! $this->getSubmitLabel() || $this->isSubmitted()) {
if ($this->isValid($formData) if ($this->isValid($formData)
&& (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $request)) && (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $request, $this))
|| ($this->onSuccess === null && false !== $this->onSuccess($request)))) { || ($this->onSuccess === null && false !== $this->onSuccess($request)))) {
$this->getResponse()->redirectAndExit($this->getRedirectUrl()); $this->getResponse()->redirectAndExit($this->getRedirectUrl());
} }