O'Reilly logo

Mastering Yii by Charles R. Portwood II

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Widgets

In Yii2, widgets are reuseable code blocks that are used in views to add configurable user interface logic to our application in an object-oriented way. Yii2 comes with several different types of reusable widgets, some of which we have already seen in previous chapters. Custom widgets can also be created to create tools that can be reused across multiple projects. In this section, we'll go over the basic types of widgets, how to use them, and how to implement our own within our applications.

Using widgets

As a presentation layer tool, widgets are most commonly used within our view files. In Yii2, widgets can be used in one of two distinct ways. The first way to use widgets is to call the yii\base\Widget::widget() method on a supported widget ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required