Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

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.
So I solved it with adding function configureFields with code from symfony doc:

public function configureFields(string $pageName): iterable
{
return [
IdField::new('id')->onlyOnIndex(),
Field::new('author'),
TextareaField::new('text'),
EmailField::new('email'),
DateTimeField::new('createdAt'),
AssociationField::new('conference'),
];
}

and it works.

Please tell me, maybe it was another way because I'm new to symfony.

You must be logged in to vote

oh, sorry, I saw this info was below

Replies: 5 comments · 1 reply

Comment options

oh, sorry, I saw this info was below

You must be logged in to vote
0 replies
Answer selected by lyrixx
Comment options

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"

You must be logged in to vote
1 reply
@danyk4
Comment options

Hi
if you'll do all the same as in doc it is working. My problem was slightly another than yours.
check everything carefully

Comment options

mine also didnt work, any help on this ?

You must be logged in to vote
0 replies
Comment options

looks like this is bad book chapter. I got 2 error. One of them the same.
If you not be able to create a good job - do not do it. We are are not monkeys which beat a keyboard.

You must be logged in to vote
0 replies
Comment options

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,

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.