Is there a way to show custom error message on screen when the validation in the before save script not passed?
Announcement
Collapse
No announcement yet.
Show custom error message on screen
Collapse
X
-
Hi
I have created a TEST entity. In the system generated custom\Espo\Custom\Repositories\TEST.php, i added a beforeSave function in the file. Code is as follows:
<?php
namespace Espo\Custom\Repositories;
use Espo\Core\ORM\Entity;
use Espo\Core\Exceptions\Error;
use Espo\Core\Exceptions\Conflict;
class TEST extends \Espo\Core\Templates\Repositories\Base
{
protected function beforeSave(Entity $entity, array $options = [])
{
parent::beforeSave($entity, $options);
throw new Error('it is a custom error');
}
}
}
An error message 'it is a custom error' is shown on the screen when i save the record of TEST entity
- Likes 1
Comment
Comment