0

Is it possible to abort a save operation in a Joomla controller? (Admin Side)

For example: I have a view with a list of items. I hit the New Item button and in the next page I enter all required fields and hit save. My form also has a file upload field for uploading a small image. That image has to be 25 by 25 pixels or else the new item won't be saved.

The only way I found so far to abort the save operation (if an error like the image size is found) is to call the cancel() method parent::cancel(); in the controller. This takes the user back to the list of items. I need to know if there's another method that will reload the new item form view with all the fields filled from the previous post so the user can just select a correct image and re-post the form without the need to fill all the fields from scratch.

Currently I'm fine with the cancel() method and if the user hits the browser's back button he will probably get back to the form with all the fields loaded, but I was just wondering if there is a way to reload the form.

droplet
  • 286
  • 4
  • 13

1 Answers1

1

I don't think there is a way to accomplish this without doing a lot of coding and hacking. Have you considered trying to gauge the size of the image using JavaScript before the image is uploaded? Or allowing people to save the normal data first and then ask for the image?

Søren Beck Jensen
  • 1,676
  • 1
  • 12
  • 22
  • For the time being I'm satisfied with the current functionality, but I've seen it work even in my component when you try to save an empty field which is required... the user gets redirected back to the form with it's state he left it before hitting save. I just might digg in into the core files and maybe find that functionality... – droplet Jul 22 '12 at 18:18
  • In the older Joomla versions they would use Javascript to go back in your history, but I am quite sure this is no longer used. – Søren Beck Jensen Jul 23 '12 at 13:12
  • You are correct, it's not JS it's a redirect call from withing the controller or the model. – droplet Jul 23 '12 at 22:51