Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3924

SonataAdmin create entity with boolean field

$
0
0

I have this entity, if I create a record like this.

$synopsis = new Synopsis();
$synopsis->setPartOne("a");
$synopsis->setPartTwo("b");
$synopsis->setTitle("A");
$synopsis->setSubtitle("B");
$synopsis->setEnabled(false);

$em->persist($synopsis);
$em->flush();

And then I go to my Admin, I see the enabled field to "no" which is expected.

But now, If I use the sonata admin new form field, even if I choose enabled "no", the record is created with enabled = true. And I don't really see why it would be like that.

Here is what I have in my SynopsisAdmin

protected function configureFormFields(FormMapper $formMapper)
{
    $formMapper->add('title', TextType::class);
    $formMapper->add('subtitle', TextType::class);
    $formMapper->add('partOne', TextAreaType::class);
    $formMapper->add('partTwo', TextAreaType::class);
    $formMapper->add('enabled', BooleanType::class);
}

This is how the enabled field is defined in the entity

/**
 * @ORM\Column(type="boolean")
 */
private $enabled;

Thanks for your help.

EDIT: Fun facts too, even if I see no in the sonata view list, when I go to the form view, I see yes instead.

I suspect an error within the sonata core functionnality.


Viewing all articles
Browse latest Browse all 3924

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>