Form: Register form notifications as custom error messages for API requests

I'd have liked to fix how we transmit validation messages in such cases,
but for compatibilty reasons this has to suffice..
This commit is contained in:
Johannes Meyer 2017-07-13 13:00:24 +02:00
parent 96c96df636
commit ed5ba14df2
1 changed files with 18 additions and 3 deletions

View File

@ -1580,7 +1580,12 @@ class Form extends Zend_Form
*/
public function error($message, $markAsError = true)
{
$this->addNotification($message, self::NOTIFICATION_ERROR);
if ($this->getIsApiTarget()) {
$this->addErrorMessage($message);
} else {
$this->addNotification($message, self::NOTIFICATION_ERROR);
}
if ($markAsError) {
$this->markAsError();
}
@ -1598,7 +1603,12 @@ class Form extends Zend_Form
*/
public function warning($message, $markAsError = true)
{
$this->addNotification($message, self::NOTIFICATION_WARNING);
if ($this->getIsApiTarget()) {
$this->addErrorMessage($message);
} else {
$this->addNotification($message, self::NOTIFICATION_WARNING);
}
if ($markAsError) {
$this->markAsError();
}
@ -1616,7 +1626,12 @@ class Form extends Zend_Form
*/
public function info($message, $markAsError = true)
{
$this->addNotification($message, self::NOTIFICATION_INFO);
if ($this->getIsApiTarget()) {
$this->addErrorMessage($message);
} else {
$this->addNotification($message, self::NOTIFICATION_INFO);
}
if ($markAsError) {
$this->markAsError();
}