Adding database entry from panel (comments example from the guide)

First of all: Happy New Year to everyone!

I’m trying to follow this tutorial and getting it to work, but i fail adding/inserting new entries from the panel.

When i try to add a comment/page after submitting the page creation dialog it directly says “page could not be found”, and when i manually add an entry to the database (via PHPMyAdmin for example) and try to create a page with the same title, there is an error saying “a page with this slug already exists”, so the system does find existing db entries. What am i missing here? Deleting and editing from the panel works fine. I’m sorry, the screenshots are in german.


I found the solution here in an old topic. When inserting you have to mention every field, even if empty. Quite confusing and i didn’t find a single hint in the docs.

so change this:

$data['slug'] = $this->slug();
return Db::insert('comments', $data);

to this:

return Db::insert('comments', [
				'slug'  => $this->slug(),
				'text'  => '',
				'user'  => '',
				'title'  => '',
				'status'  => ''
]);

and it works.

Now i can adapt to my needs.

What does your database table setup look like, the example in the docs should work as intended unless you have set your fields to Not NULL. This is the field setup I was using:

Makes sense now that you mention it, but that info is missing in the example. I just quickly tried to build that table with PHPMyAdmin from what i saw in the article and “not null” seems to be the default in PHPMyAdmin (local MAMP). Thing is that i didn’t get any hint or clue from the error-message where to look for mistakes. Debugging is on but didn’t show up.