On_before_delete function

edited September 2011 in Modules
So I have a model that handles some slides I have in the page. My problem is having a fail safe in case the file doesn't delete. What would I have to return so the delete method only runs once the on_before_delete succeeds?

Comments

  • edited 12:17PM
    Also I'm having a bit of a problem with saving a file I get "You did not select a file to upload." as an error message. Basically the only thing I did was:

    function form_fields($values = array(), $related = array()) {
    $fields = parent::form_fields($values, $related);

    $fields['file']['type'] = 'file';

    return $fields;
    }

    Am I possibly doing something wrong?
  • edited 12:17PM
    I might not be understanding correctly, but for a fail safe, couldn't you just return true or false from on_before_delete and then in the delete method pass in that variable and check to see whether it's true or false?
  • edited 12:17PM
    I think in your case, you may just want to overwrite the model's delete method with your own logic.
  • edited 12:17PM
    I thought maybe the delete method might check what the result of on_before_delete is. Also any help with my second problem with the insert? That would be great. :) Thanks in advance.
  • edited 12:17PM
    The on_before_delete() hook doesn't check for anything returned... it just runs (see line 1194 of MY_Model).

    With regards to the saving issue, I wasn't able to replicate that problem locally. Are you using another model hook to process the file? That error is thrown by the CI's Upload class.
Sign In or Register to comment.