GuestBook error in chapter Setting up an Admin Backend #47082
-
|
I did everything but with empty "function configureFields()" in CommentCrudController.php I've got an error while trying to add a new comment: An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'conference_id' cannot be null I've noticed that there was no field "conference name" in a comment creation form and understood that it is about connection with Conference field. public function configureFields(string $pageName): iterable and it works. Please tell me, maybe it was another way because I'm new to symfony. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments · 1 reply
-
|
oh, sorry, I saw this info was below |
Beta Was this translation helpful? Give feedback.
-
|
Hello, I do not quite understand how you solved the problem? I have about the same error. " An exception occurred while executing a query: SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "conference_id" of relation "comment" violates not-null constraint" |
Beta Was this translation helpful? Give feedback.
-
|
mine also didnt work, any help on this ? |
Beta Was this translation helpful? Give feedback.
-
|
looks like this is bad book chapter. I got 2 error. One of them the same. |
Beta Was this translation helpful? Give feedback.
-
|
AFAIU, there's a missing step, which relates to configuring the fields of the comment, i.e. having the conference reference displayed in the form (and list). The diff shown later show that configureFields() isn't commented, but AFAIU, currently, the make:admin:crud will generate a commented-out configureFields() method. So I guess there should be an additional paragraph, right before the addition of Conference::_toString() which uncomments and changes the method to : public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('conference'),
TextField::new('author'),
EmailField::new('email'),
TextareaField::new('text'),
TextField::new('photoFilename'),
DateTimeField::new('createdAt')
];
}Which exhibits the need to add __toString to Conference... and then hopefuly gets rid of the PSQL constraint violation error. And then only, one can proceed to fine tuning the rest of the Admin CRUD as in current docs. Hope this helps, |
Beta Was this translation helpful? Give feedback.
oh, sorry, I saw this info was below