in yii2 select2 how to add value in database if that option does not exists
<p>How to add category in database if that does not exists in yii2 select2.</p>

<pre><code>&lt;?= 
    $form-&gt;field($model, 'question_category')-&gt;widget(Select2::classname(), [
        'data' =&gt; ArrayHelper::map(Category::find()-&gt;all(),'category_name','category_name'),
        'maintainOrder' =&gt; true,
        'toggleAllSettings' =&gt; [
            'selectLabel' =&gt; '&lt;i class="glyphicon glyphicon-ok-circle"&gt;&lt;/i&gt; Tag All',
            'unselectLabel' =&gt; '&lt;i class="glyphicon glyphicon-remove-circle"&gt;&lt;/i&gt; Untag All',
            'selectOptions' =&gt; ['class' =&gt; 'text-success'],
            'unselectOptions' =&gt; ['class' =&gt; 'text-danger'],
        ],
        'options' =&gt; ['multiple' =&gt; true, 'placeholder' =&gt; 'Select a Category ...'],
        'pluginOptions' =&gt; [
            'tags' =&gt; true,
            'maximumInputLength' =&gt; 10
        ],
    ]);
?&gt;
</code></pre>