<p dir="auto">With the latest 2.5 dev branch (but also with v2.5.0-BETA1), it's no longer possible to serialize a FormView instance. When trying, <code class="notranslate">Exception: Serialization of 'Closure' is not allowed</code> is thrown, see <a href="https://travis-ci.org/craue/TwigExtensionsBundle/builds/24253905" rel="nofollow">https://travis-ci.org/craue/TwigExtensionsBundle/builds/24253905</a>.</p>
<p dir="auto">This would be needed for <a href="https://github.com/craue/TwigExtensionsBundle/blob/dc4ffd5e5239c50c5d7b0fa7fe10fae40ebe653b/Twig/Extension/FormExtension.php#L73">https://github.com/craue/TwigExtensionsBundle/blob/dc4ffd5e5239c50c5d7b0fa7fe10fae40ebe653b/Twig/Extension/FormExtension.php#L73</a> to work.</p>
<p dir="auto">Hi all,</p>
<p dir="auto">I have a weird issue that I can't figure out why.</p>
<p dir="auto">I have an entity <code class="notranslate">User</code>, which has a boolean field <code class="notranslate">enabled</code>. When I try to update the entity with a form, all other non-boolean fields are updated, only the booleans are always set to true. I dumped <code class="notranslate">$request-&gt;request-&gt;get('form_name')</code>, the result looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="UserController.php on line 108:
array:1 [▼
  &quot;form_name&quot; =&gt; array:12 [▼
    ...
    &quot;enabled&quot; =&gt; &quot;0&quot;
    ...
  ]
]"><pre class="notranslate"><code class="notranslate">UserController.php on line 108:
array:1 [▼
  "form_name" =&gt; array:12 [▼
    ...
    "enabled" =&gt; "0"
    ...
  ]
]
</code></pre></div>
<p dir="auto">And I call <code class="notranslate">$form-&gt;handleRequest($request)</code>, then I dumped the entity, expecting it to be updated.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="UserController.php on line 109:
User {#3066 ▼
  ...
  #enabled: true
  ..."><pre class="notranslate"><code class="notranslate">UserController.php on line 109:
User {#3066 ▼
  ...
  #enabled: true
  ...
</code></pre></div>
<p dir="auto">I don't really understand now, it happens to this particular form, I haven't had such a problem before, and I run out of ideas as to why it happens.</p>
<p dir="auto">As an interim solution, I set the boolean values directly on the entity after the <code class="notranslate">handleRequest()</code> call. Something like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$form-&gt;handleRequest($request);

// set the boolean fields on the entity because handleRequest can't update these fields for some reason
$user-&gt;setEnabled(!!$data['form_name']['enabled']);"><pre class="notranslate"><code class="notranslate">$form-&gt;handleRequest($request);

// set the boolean fields on the entity because handleRequest can't update these fields for some reason
$user-&gt;setEnabled(!!$data['form_name']['enabled']);
</code></pre></div>