0
0

BaseForm.php 430 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace backend\forms;
  3. use yii\base\Model;
  4. use components\Exception;
  5. /**
  6. * Class BaseForm
  7. * @package backend\forms
  8. */
  9. class BaseForm extends Model
  10. {
  11. public function handleError()
  12. {
  13. $errors = $this->getFirstErrors();
  14. $result = reset($errors);
  15. if (is_numeric($result)) {
  16. throw new Exception($result, \Yii::t('error', $result));
  17. } else {
  18. throw new Exception(1003, $result);
  19. }
  20. }
  21. }