Conditional validation using scenarios in yii2
<p>I am trying to validate my form in edit scenario where if <code>CandidateResumeName</code> is not filled, I want to require this field. This is how I am trying, but it's not working.</p>

<pre><code>[['CandidateResumeName'], 'required', 'when' =&gt; function($model) {                              
                if($model-&gt;HRMS_CandidateResumeName == "")
                    return true;
                },'on' =&gt; 'edit'],  
</code></pre>

<p>Please help!</p>