<p dir="auto">I'm trying to use the setDefaults method in a form type, but I can't figure out how to merge options with defaults, I'm doing this :</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php

// Creating the form
$form = $factory-&gt;create('my_type', null, array(
    'test' =&gt; array(
        'tata' =&gt; true,
    )
));

// FormType Class
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver-&gt;setDefaults(array(
        'test' =&gt; array(
            'toto' =&gt; true,
            'tata' =&gt; false,
        )
    ));
}

// Resolved options
array(
    'test' =&gt; array('tata' =&gt; true)
)

// I was trying to get
array(
    'test' =&gt; array('tata' =&gt; true, 'toto' =&gt; true)
)"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>

<span class="pl-c">// Creating the form</span>
<span class="pl-s1"><span class="pl-c1">$</span>form</span> = <span class="pl-s1"><span class="pl-c1">$</span>factory</span>-&gt;<span class="pl-en">create</span>(<span class="pl-s">'my_type'</span>, <span class="pl-c1">null</span>, <span class="pl-en">array</span>(
    <span class="pl-s">'test'</span> =&gt; <span class="pl-en">array</span>(
        <span class="pl-s">'tata'</span> =&gt; <span class="pl-c1">true</span>,
    )
));

<span class="pl-c">// FormType Class</span>
<span class="pl-k">public</span> <span class="pl-k">function</span> <span class="pl-en">setDefaultOptions</span>(<span class="pl-smi"><span class="pl-smi">OptionsResolverInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>resolver</span>)
{
    <span class="pl-s1"><span class="pl-c1">$</span>resolver</span>-&gt;<span class="pl-en">setDefaults</span>(<span class="pl-en">array</span>(
        <span class="pl-s">'test'</span> =&gt; <span class="pl-en">array</span>(
            <span class="pl-s">'toto'</span> =&gt; <span class="pl-c1">true</span>,
            <span class="pl-s">'tata'</span> =&gt; <span class="pl-c1">false</span>,
        )
    ));
}

<span class="pl-c">// Resolved options</span>
<span class="pl-en">array</span>(
    <span class="pl-s">'test'</span> =&gt; <span class="pl-en">array</span>(<span class="pl-s">'tata'</span> =&gt; <span class="pl-c1">true</span>)
)

<span class="pl-c">// I was trying to get</span>
<span class="pl-en">array</span>(
    <span class="pl-s">'test'</span> =&gt; <span class="pl-en">array</span>(<span class="pl-s">'tata'</span> =&gt; <span class="pl-c1">true</span>, <span class="pl-s">'toto'</span> =&gt; <span class="pl-c1">true</span>)
)</pre></div>
<p dir="auto">How can I achieve this? Thanks</p>
<p dir="auto">It is currently not possible to configure nested options. For example:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$resolver-&gt;setDefaults(array(
    'db' =&gt; array(
        'dsn' =&gt; null,
        'user' =&gt; 'root,
        'password' =&gt; '',
        'port': 3306,
    ),
));"><pre class="notranslate"><span class="pl-s1"><span class="pl-c1">$</span>resolver</span>-&gt;<span class="pl-en">setDefaults</span>(<span class="pl-en">array</span>(
    <span class="pl-s">'db'</span> =&gt; <span class="pl-en">array</span>(
        <span class="pl-s">'dsn'</span> =&gt; <span class="pl-c1">null</span>,
        <span class="pl-s">'user'</span> =&gt; <span class="pl-s">'root,</span>
<span class="pl-s">        'password' =&gt; ''</span>,
        <span class="pl-s">'port'</span>: <span class="pl-c1">3306</span>,
    ),
));</pre></div>
<p dir="auto">It is not possible to resolve this configuration in the following way:</p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$resolver-&gt;resolve(array(
    'db' =&gt; array(
        'dsn' =&gt; ...
    ),
));"><pre class="notranslate"><span class="pl-s1"><span class="pl-c1">$</span>resolver</span>-&gt;<span class="pl-en">resolve</span>(<span class="pl-en">array</span>(
    <span class="pl-s">'db'</span> =&gt; <span class="pl-en">array</span>(
        <span class="pl-s">'dsn'</span> =&gt; <span class="pl-c1">.</span>.<span class="pl-c1">.</span>
    ),
));</pre></div>
<p dir="auto">because now the other default values under "db" will be dropped. Also, it is not possible to specify allowed values or types for the nested options.</p>