BlockController save method issue

Permalink
Hi,

I try to make a custom block type. I built the controller.php according to the example and overwrote save method of the parent BlockController class. Block adding and editing works well until I quit from edit mode and publish my edit. When I go back (edit page) and try to update the properties of the existing block by clicking on the update button, C5 throws a "Fatal error: Uncaught exception "ADODB_Exception with message 'mysql error'..". It's like c5 does not call save method of my controller, but something else. I tested it with a die() function at the very beginning of my save() method. This die() stopped the running successfully when the block added first time or edited before publishing, but did nothing after publishing when I tried to edit the block again. Any ideas?

 
olliephillips replied on at Permalink Reply
olliephillips
You might want to post some code, it will be easier for people to help you that way.

But guessing. I'd check your block's database table is installed, and correctly and, if you are "overriding" the save method in your blocks controller, you should make sure you call the parent method when you're done.

i.e.
parent::save($args);
megant replied on at Permalink Reply
Thank you for quick reply olliephillips.

Code is not important, because it works (as I wrote above). My save method handles every database insert and update query, so does not need to call parent::save($args) method. The problem is my save method seems not to be called after block publishing and reediting.
mkly replied on at Permalink Reply
mkly
"Code is not important, because it works(as I wrote above)."

Jeez, that's a tough way to ask someone to help you out in their free time.

The save method is called when you click "Add" and "Update" in the block form.

It does not run when you click "Publish"

If you would like to have a better time debugging this I recommend this

public function save(){
  $l = new Log('Debug Save Method');
  $l->write('Block of type "' . $this->getBlockTypeName() . '" and id of "' . $this->getIdentifier() . '" save method called.');
  $l->close();
}


And then check your concrete5 logs at
Dashboard->Reports->Logs

Hopefully that will be of some help.
megant replied on at Permalink Reply
I found a difference between two editing progression (before and after publishing). When I added the block and edited before publishing, the hidden input field named: "ccm-block-form-method" was set to "REGULAR", and when I tried to edit the block after publishing, the same field was set to "AJAX". Does it make any sense for anybody?
megant replied on at Permalink Reply
If I completely comment the whole content of the save method out, there is no changing at all, just the same error message. Can it be some kind of cache bug? I disabled every kind of caching.
joseajohnson replied on at Permalink Reply
joseajohnson
It would be helpful to know what the mySQL error was, and, as @olliephillips pointed out, any code would be invaluable; even if all of the juicy bits were substituted with placeholders.

On the surface, it sounds like the system is choking on a query for a nonexistent block - again, pretty much what @olliephillips pointed out.

Good luck!