Restrict deletion if relation exists

edited January 2016 in Feature Requests
I have a question... is it possible with standard Fuel CMS features to use a validation to restrict data beeing deleted if there are open relations.

So if you want to delete a record which is used as foreign key in other modules.

For example a page has images defined, which are used in the layout. So via a module you can assign multiple images to the base page recordset. Now if this image should be deleted I don't want the relation to be deleted but instead give an error, that the record is not allowed to be deleted.

Is that possible?

Comments

  • edited January 2016
    or alternativly a decision page with a warning text: are u sure u want to delete, because u would break up the relation
  • edited 1:44PM
    The on_before_delete method could be used to check the relationship data and if it exists, set an error on the model which will prevent the deletion from happening.
    public function on_before_delete($where)[ { if ($this->do_validation_check_method_for_relationships()) { $this->add_error('This record cannot be deleted because of associated relationships.'); } else { parent::on_before_delete($where); } }
Sign In or Register to comment.