Form: Respond w/ JSON-encoded messages if API requests fail

refs #9606
This commit is contained in:
Eric Lippmann 2015-08-20 15:48:42 +02:00
parent 0fb495f541
commit dd23bd9397
1 changed files with 5 additions and 0 deletions

View File

@ -1074,6 +1074,11 @@ class Form extends Zend_Form
} else {
$this->getView()->layout()->redirectUrl = $this->getRedirectUrl()->getAbsoluteUrl();
}
} elseif ($this->getIsApiTarget()) {
$this->getRequest()->sendJson(array(
'status' => 'fail',
'data' => array_merge($this->getMessages(), $this->getErrorMessages())
));
}
} elseif ($this->getValidatePartial()) {
// The form can't be processed but we may want to show validation errors though