[Flow] Validator is not called ...
Zedd
zedd at akii.de
Tue Mar 31 17:01:02 CEST 2015
Hi,
before validation takes place, the property mapper must build the object (some magic applies).
In short: Adjust the typehint of the function myObject::setCar() to allow NULL values.
setCar(Car $car = NULL)
Greetings,
Philipp
> On 31 Mar 2015, at 16:31, Tomas M <flow at 46dev.de> wrote:
>
> Hello!
>
> I have defined two classes; both are presisted in db (see code snipped below).
>
> In the according form the user selects one "car" from a select box.
> As long the user really selects one, all is fine.
>
> But if the field is left blank I get
>
> Exception while property mapping for target type "My\Pkg\Domain\Model\myObject", at property path "":
> Catchable Fatal Error: Argument 1 passed to My\Pkg\Domain\Model\myObject_Original::setCar() must be an instance of My\Pkg\Domain\Model\Car, null given ....
>
>
> First I've used
> @Flow\Validate(type="NotEmpty")
>
> but I got exactly the same message.
> My validator is called only, if a "car" was selected
> else I get the message above.
>
>
> What I'm doing wrong?
>
> Does someone have an idea?
>
>
>
>
>
>
> /**
> * @Flow\Entity
> */
> class myObject {
>
> /**
> * @var string
> *
> * @Flow\Validate(type="Text")
> * @Flow\Validate(type="StringLength", options={ "minimum"=5, "maximum"=80 })
> * ORM\Column(length=255)
> */
>
> protected $theLabel;
>
>
> /**
> * @var \My\Pkg\Domain\Model\Car
> * @Flow\Validate( argumentName="car", type="\My\Pkg\Validation\Validator\myObjectValidator", options={})
> * @ORM\ManyToOne
> */
>
> protected $car;
>
>
> ...
>
>
> }
> _______________________________________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
More information about the Flow
mailing list