Skip to content

make:entity setter for non nullable fields must allow null values to allow validating #273

Open
@HKandulla

Description

@HKandulla

This is closely related to #198.

As @javiereguiluz comments, all setters - even for nullable fields - must allow null values to be passed in order for the validation to work. At the moment:

   /**
     * @ORM\Column(type="integer", nullable=false)
     * @Assert\NotNull()
     */
    private $adpointPublicationId;

generates:

    public function setAdpointPublicationId(int $adpointPublicationId): self
    {
        $this->adpointPublicationId = $adpointPublicationId;

        return $this;
    }

so when null values passed through a form, we get the following error before validation is done.

Argument 1 passed to App\Entity\Product::setAdpointSectionGroupId() must be of the type integer, null given, called in .../backend/vendor/symfony/property-access/PropertyAccessor.php on line 527
Exception

Thanks, Hannes

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugBug Fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions