/** * Throw validation exception or append errors to form if it exists * @throws fx_entity_validation_exception */ protected function throwInvalid() { $exception = new Exception\EntityValidation(fx::lang("Unable to save entity \"" . $this->getType() . "\"")); $exception->entity = $this; $exception->addErrors($this->validate_errors); $form = $this->getBoundForm(); if ($form) { $exception->toForm($form); } else { throw $exception; } }