How to add a post button along with each record in my view?

I am displaying the contents of my table in it’s view using the default CGridView option. For each record I display in my view, I want to include a button (with POST functionality) which will trigger a action (common to all records) within the controller.

Basically, I am trying out an shopping site example where all products are listed on the screen with a "Buy" button next to each of them. When the user presses the "Buy" button of a particular item, it should trigger an action to capture the order info including the ordered item details along with the user details for further processing.

What is the most elegant way of including this "Buy" button for each record/item getting displayed in the view?

Need your recommendation please. Any similar example is appreciated.

U will have to make button column custom to fit your need:

add last column id grid view:


‘class’ => ‘bootstrap.widgets.TbButtonColumn’,

‘template’=>’{what ever U need}’,

… configurin each button to fit your need …


please check this:

1 Like