title: Displaying a pop up message and validation Yii2
body: <p>In my view.php I have a close ticket button. When I select that button it will automatically get the system time and the status will be change into 'Done'.</p>
  
  <p>What I want to try is that when I click the close button if the ticket has already been done, the time_end won't be changed and it will display a popup message similar to the delete button. </p>
  
  <p>Here's my code:</p>
  
  <pre><code>public function actionClose($id)
  {
      $model = $this-&gt;findModel($id);
   //     $model-&gt;status = ('Done');
   //     $model-&gt;time_end = date('y-m-d h-i-s');
   //     $model-&gt;save();
   //     return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
  
      if ($model-&gt;status == 'Done' &amp;&amp; $model-&gt;time_end == date('y-m-d h-i-s')) {
          (['data' =&gt; ['prompt' =&gt; 'Ticket has already been closed!']]);
      } else {
          $model-&gt;status = ('Done');
          $model-&gt;time_end = date('y-m-d h-i-s');
          $model-&gt;save();
          return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
  
  }
  </code></pre>
  
  <p>My problem is that when click the close button and I select a ticket that has a status 'Done' and already has a time end, it still gets the time_end even though the ticket status is already 'Done'. How do I prevent it from happening like some sort of validation with a pop up message similar to the delete button in the view.php</p>