BlockController::save - throw validation errors
Permalink
I'm building a new block for the Marketplace (Concrete 5.7 +). In the controller I'm overriding save before calling save on the parent (I have two extra tables).
My question : how to throw an error when the block is saved? I'm doing clientside validation but I also do some serverside validation on database related stuff and if that fails I should be able to throw an error to prompt the user. Throwing an exception works as far as the error being shown to the user, but if the user resolves the problem and hits the save button a second time, I get a Concrete exception where it's calling getInstance on a none-object. I tried this in two other blocks to see if it was related to this specific block but had the same problem here. I'm guessing some form token is sent the first time and expires when I submit the form a second time. I think I remember doing this without issues in 'old' Concrete 5 versions ( < 5.7).
Does anyone know : Is this possible at all, and if so, what is the correct way to convey the error and break off the save method? (I also tried just echoing the error and calling 'exit()', also same problem)
My question : how to throw an error when the block is saved? I'm doing clientside validation but I also do some serverside validation on database related stuff and if that fails I should be able to throw an error to prompt the user. Throwing an exception works as far as the error being shown to the user, but if the user resolves the problem and hits the save button a second time, I get a Concrete exception where it's calling getInstance on a none-object. I tried this in two other blocks to see if it was related to this specific block but had the same problem here. I'm guessing some form token is sent the first time and expires when I submit the form a second time. I think I remember doing this without issues in 'old' Concrete 5 versions ( < 5.7).
Does anyone know : Is this possible at all, and if so, what is the correct way to convey the error and break off the save method? (I also tried just echoing the error and calling 'exit()', also same problem)