<p dir="auto">DateTimeType, when used with the widget "text", currently duplicates the invalid error when an invalid value is entered.</p>
<p dir="auto">Also, it should be possible to configure the "invalid" messages of both the "date" and the "time" field.</p>
<p dir="auto">Suppose you have an entity "Task" with a "status" property of type Integer (stored in the database as an integer).</p>
<p dir="auto">You can define an action to set the status of a Task as:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  /**
   * @ParamConverter(&quot;task&quot;, options={&quot;mapping&quot;: {&quot;task_id&quot;: &quot;id&quot;}})
   */
  public function settaskstatusAction($status, Task $task) {
    $em = $this-&gt;getDoctrine()-&gt;getManager();
    $task-&gt;setStatus($status);
    $em-&gt;persist($task);
    $em-&gt;flush();
    return $this-&gt;render(...);
  }"><pre class="notranslate">  <span class="pl-c">/**</span>
<span class="pl-c">   * @ParamConverter("task", options={"mapping": {"task_id": "id"}})</span>
<span class="pl-c">   */</span>
  <span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">settaskstatusAction</span>(<span class="pl-s1"><span class="pl-c1">$</span>status</span>, <span class="pl-smi"><span class="pl-smi">Task</span></span> <span class="pl-s1"><span class="pl-c1">$</span>task</span>) {
    <span class="pl-s1"><span class="pl-c1">$</span>em</span> = <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">getDoctrine</span>()-&gt;<span class="pl-en">getManager</span>();
    <span class="pl-s1"><span class="pl-c1">$</span>task</span>-&gt;<span class="pl-en">setStatus</span>(<span class="pl-s1"><span class="pl-c1">$</span>status</span>);
    <span class="pl-s1"><span class="pl-c1">$</span>em</span>-&gt;<span class="pl-en">persist</span>(<span class="pl-s1"><span class="pl-c1">$</span>task</span>);
    <span class="pl-s1"><span class="pl-c1">$</span>em</span>-&gt;<span class="pl-en">flush</span>();
    <span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">render</span>(...);
  }</pre></div>
<p dir="auto">This works, but if your Task has a status set to 1 and you call the action with parameter '1', the <code class="notranslate">$status</code> will contain the string '1' (which is different from the integer 1) and an update will be performed on the database without any real need for it. I noticed this by using the Loggable DoctrineExtension which then also adds a useless log entry.</p>
<p dir="auto">Of course it is easy to correct this by casting the <code class="notranslate">$status</code> value myself, but as Integer fields will be casted to int before being stored, I believe they could be casted before the comparison.</p>