Symfony 3 DTOOneCommand changing null value to 0 after handleRequest

130 views Asked by At

I am working on a Symfony 3 project and I am facing a problem. When my form is submitted it changed the value from null to zero. But I would like that it keeps value it is sent. Because for me null is different than 0.

I have dump like (form use create form from scenarioProposalVersionModelizeCommand):

    dump($scenarioProposalVersionModelizeCommand->phaseProposalVersions[0]);
    $form->handleRequest($request);
    dump($scenarioProposalVersionModelizeCommand->phaseProposalVersions[0]);die;

Output so this 3 last values as you can see are transformed:

enter image description here

1

There are 1 answers

0
MaxiGui On BEST ANSWER

I was going over the problem by using directly information from request.

Using php condition to treat the value: ""

if(empty($value) && strlen($value) == 0)
  $value = null;

But question is still valid.