Skip to content

Don't require an object property to be readable for writing #36754

Closed
@ph-fritsche

Description

@ph-fritsche

Description

As dicussed in #36492 the Symfony\Component\Form\Extension\Core\PropertyPathMapper does not behave as expected.
When trying to write form values to an object it fails if the property is not readable.

The current implementation tries to get the value to avoid setting an identical value.

PropertyPathMapper should catch any exceptions that are specific to reading the property when trying to write it.

It might set an identical value.
If writing fails, an exception will still be thrown as expected.

Example

class Foo1 {
    public int $bar;
}

One should be able to map a form with bar=123 to Foo1, but it will fail with UninitializedPropertyException.

class Foo2 {
    private $bar;
    public function setBaz($value) {
        $this->bar = $value * 2;
    }
}

One should be able to map a form with baz=123 to Foo2, but it will fail with a NoSuchPropertyException.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FormRFCRFC = Request For Comments (proposals about features that you want to be discussed)Stalled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions