Why the Add Button on my new block doesn't do anything

Permalink 1 user found helpful
One of the most frustrating issues I've come upon since getting in to C5 block development is figuring out why the Add button on my new block doesn't work (it does nothing). No JS errors are triggered and there is otherwise no obvious reason for it.

I'm hoping this post becomes a resource for 'hidden' reasons why your new block won't add.

I've solved this problem once before, but admittedly can't remember how, so if you can think of any reasons why this would occur, you would help me (and hopefully others) both now and in the future.

Thanks!
Dan

dvodvo
 
dvodvo replied on at Permalink Reply
dvodvo
Reason #1

Having input elements in your Add/Edit code with IDs that do not match DB entries in db.xml. This happens to me sometimes because I'm using AJAX within my Add/Edit forms, or think to use a hidden input to store an intermediate value, in both cases I don't want these printing to the DB but the block control will automatically. Suppose you can avoid if you need extra inputs by writing a custom save() in your controller.php.
NUL76 replied on at Permalink Reply
NUL76
Do you've got a link to your site?

Is it possible that you've added jquery files yourself. So that there are two of the same jquery files in your site, because C5 adds the jquery file automatically?! That happened to me once and fixed the problem by deleting the jquery which I've added in my theme.
dvodvo replied on at Permalink Reply
dvodvo
Actually my own reply up above solved my problem. But I figure it's still a valid issue, and given that it can be caused by at least a few invisible errors I hope the thread will continue and save people some headaches. Appreciate the input though!
jordanlev replied on at Permalink Reply
jordanlev
Another reason for this might be if you don't have both an ID field AND at least one other field (of any name/type) in your block's primary database table. Not sure why, but each block's database table must contain at least one field other than the ID field (even if you don't actually use it for anything), otherwise you get weird errors like this.
dvodvo replied on at Permalink Reply
dvodvo
I guess there's a
INSERT INTO btMasterTable () VALUES ();
somewhere that gets run without without any additional items, since bID is auto-increment, ADOdb would throw an error.
dvodvo replied on at Permalink Reply
dvodvo
Also watch your HTML. I had the button break just because I had an extra </div> in there. Another half hour lost to the sands of time...
dimunation replied on at Permalink Reply
+1 for bad HTML.

Had one block with one too many closing </div> tags. This prevented the block from submitting, even though i was able to click on the Add button (nothing would happen when it was clicked), and also successfully cancel out of the block creation with the cancel button.

Very strange behavior. Spent at least a half hour staring at database field names before discovering this.
Deladroid replied on at Permalink Reply
Deladroid
+1 also.
I had copied over a controller.php file and messed with a form display, not remembering that I deleted <div> wrapper and thanks to this thread, I added them back and my form is saving again... Thanks.
andrewsturm replied on at Permalink Reply
+1 again!

one to many </div>

Thank you for finding this.