Prettyscripts

Yii2: Authorization without RBAC

While RBAC allows you to define collection of permissions for your application, sometimes you just want something simpler to control access to certain pages. The simplest way to define your own access rule without using RBAC is to make use of $matchCallback property when definining Access Control rules. In behaviors() function in Controller or Module:

Yii2: Posting Data via Link

This seems to be undocumented (or not so well documented) at the moment. Yii2 provides special supports which allows you to post data via clicking a link. Note: Line 3: Specifying the method, eg ‘GET’, ‘POST’, ‘PUT’ Line 4: Data to be posted. To get posted data in the action:

Yii2: Typeahead widget

In Yii V1, you use CJuiAutoComplete widget which displays an autocomplete field. There’s equivalent widget in Yii2 but I’ve not tried it yet because I tried something developed by external parties before I knew it exists. I’ve had successful use with the Typeahead widget, which is a wrapper class for Twitter Typeahead jQuery plugin.