All web UIs can be grouped into two (2) based on their functions.
- Widgets that help to display data/content: For example, the tab widgets help to display content in a limited space on a page that would have otherwise required a number of pages.
- Collect user input (Form input elements): Some inputs required from our visitors to our websites require a specific format. For instance, you may require a user to enter a date in a specific format. The jQuery DatePicker can help in this case. We can also make mention of the numerous WYSIWYG editors that transforms a simple textarea.
CWidget class. This class will serve as the base class for developing any widget that falls under category one(1) above. If
$obj is an instance of
JsWidget, the following properties and methods are defined.
To develop the base class for widgets that fall under category two(2), we will create a class name JsInputWidget which will subclass our JsWidget. When developing in Yii, an instance of
CModel is usually used to collect user inputs.
JsInputWidget will be given a
CModel to work with. The following properties and methods are defined for our
/** * @var CModel the data model associated with this widget. */ public $model; B1B
You can download the classes to see the implementation of methods associated with each class.
If you are very familiar with Yii, you will notice that these two classes are clones of the Yii