Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to display a dropdown in Yii CButtonColumn
    text
    copied!<p>My requirement is to display a dropdown with add,edit,delete options which onchange event will be redirected to the corresponding action.</p> <p>Currently I have tried the below piece of code and the dropdown is getting displayed but problem is that the value of <strong>edit</strong> option is not set with the id of the record.</p> <pre><code>$this-&gt;widget('zii.widgets.grid.CGridView', array( 'id'=&gt;'blog-grid', 'dataProvider'=&gt;$model-&gt;search(), 'filter'=&gt;$model, 'columns'=&gt;array( array('header'=&gt;'Username','name'=&gt;'username', 'value'=&gt;'$data-&gt;owner-&gt;username'), array('header'=&gt;'Company','name'=&gt;'company', 'value'=&gt;'$data-&gt;owner-&gt;company','filter'=&gt;false), array('header'=&gt;'Blog Title','name'=&gt;'title','filter'=&gt;false), array('header'=&gt;'Created on','name'=&gt;'created_time','filter'=&gt;false), array('header'=&gt;'Latest activity','name'=&gt;'updated_time','filter'=&gt;false), array('header'=&gt;'URL','name'=&gt;'subdomain','filter'=&gt;false), array('header'=&gt;'Status','name'=&gt;'status','filter'=&gt;false), array('header'=&gt;'Action','class'=&gt;'CButtonColumn', 'template' =&gt; '&lt;select class="actionList" id="actionList" name="actionList"&gt; &lt;option&gt;Choose&lt;/option&gt; &lt;option value="1"&gt;Moderate&lt;/option&gt; &lt;option value="$data-&gt;id"&gt;Edit&lt;/option&gt; &lt;option value="3"&gt;Deactivate&lt;/option&gt; &lt;option value="4"&gt;Export&lt;/option&gt; &lt;option value="5"&gt;Delete&lt;/option&gt; &lt;/select&gt;' ), ), )); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload