Hi all

Is there a standard mechanism for telling why a record hasn't been
deleted?

When a record isn't deleted, it just tells "Xxx was not deleted", but
without any reason. So for example, when I'm creating a
beforeDelete(..) hook that prevents the record from deletion, how
should I let the user know why it hasn't been deleted?

Would using a $deletionError variable be an acceptable way?

function beforeDelete($cascade) {
  if($this->hasDependentRecords()) {
    $this->deletionError = 'record has dependent records';
    return false;
  }
}

And in the controller:

if ($this->Post->delete($id)) {
  ...
} else {
  $this->Session->setFlash('Post was not deleted because '.$this->Post-
>deletionError);
}

What do you think about this solution? Is there a better way?

Thanks, Josh

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to