title: YII2 - Linking actions from controller to html::button in views
body: <p>I'm currently studying Yii 2.0 framework and I've stumbled upon a question. On a tutorial I've followed on the <a href="http://www.yiiframework.com/doc-2.0/guide-start-forms.html" rel="nofollow">guide here</a>.</p>
  
  <p>In the controller, there's an action called actionEntry but there's no indication how the action knew when to be triggered.</p>
  
  <p>I've tried creating a custom controller with an action called actionAdd. It will simply render a different view once it's called. Below is the snippet I have:</p>
  
  <pre><code>public function actionAdd() {
      return $this-&gt;redirect('entry', '');
  }
  </code></pre>
  
  <p>Then on my view I've added a button using the html helper like so:</p>
  
  <pre><code>&lt;?= Html::button('Add', ['class' =&gt; 'btn btn-primary', 'onclick' =&gt; 'actionAdd()']]) ?&gt;
  </code></pre>
  
  <p>Honestly, I simply assumed that the button tag of the html helper would have an 'onclick' option because everything I've seen so far makes use of CHtml which I haven't gotten into just yet. This didn't work so my question is, how do you link controller actions to the view buttons? And how does the controller exactly know when to trigger the actions?</p>
  
  <p>Note: Note sure if it helps, my button is in my index class.</p>