Yii2 advanced doubts

So, I have just started working on Yii2 framework, the advanced template version. So far, I have been exploring and reading the main documentation on Yii2, while the documentation has been relatively great, I find a lack of guides and other documentation on Yii2, due to this I have certain questions and doubts which I hope can be answered

Firstly,While one can use ActiveForms and widgets in yii2 to generate the html required for a form and other normal Html components, I am curious whether it is possible to use just normal HTML/CSS without involving ActiveForms? Also, are there any possible alternatives to ActiveForm and how would that affect the performance of the application?

Secondly, while I use external bootstrap and css files,I find it relatively difficult to customise the look of my application. So is it just me who requires more experience or is it a common thing about Yii2.

Lastly,how does one use normal Ajax and jquery in Yii2?This is my first MVC framework frankly, I would use normal Html/css,php,jquery,ajax before all this. I have understood the Model View Controller structure in Yii2 advanced perfectly, If I could just gain a little more insight from this community, it would be great!

Hi and welcome,

You are not forced to use ActiveForm or anything else provided by the Framework.

You can always write plain HTML/CSS and use it in your views. ;)

And while this seems to be more easy (at first) it would come come with disadvantages.

ActiveForm does a lot of stuff for you, that you would have to do yourself… For example Client validation, Ajax-Validation and the display of all the error messages received from your Model etc.

Regarding the Guides? Is there anything special you’re looking for? Actually I find tons of Guides / Tutorials for yii2 with a quick Google search? :)

Lastly, what exactly do you mean with "how does one use normal Ajax and jquery in Yii2"?

Please give an example what exactly you’re looking for or not understanding? :)

A small start on Pjax, which should give you a clue about concepts can be found here:

Link: http://blog.neattutorials.com/yii2-pjax-tutorial/

Or just Google for "Yii2 Pjax Tutorial" and a lot of concepts should become clear.


You may always use plain html/css/javascript without using ActiveForm or widgets like GridView, ListView, and DetailView provided by Yii.

But as MetaCrawler says, you’ll be much more productive by making use of those things, because they will do a lot of standard jobs (i.e., CRUDs) for you when you have to deal with database related jobs.

A helper class “Html” can provide all the functionality that ActiveForm does. And there’s no performance penalty using it, but no performance boost either. In fact, ActiveForm depends on Html.

The difference lies in the fact that ActiveForm needs to be used with “Model” class. And once you have decided to use “Model” (or “ActiveRecord”) to handle your data, then you’ll find that ActiveForm is much more convenient. (And this is also true with the widgets like GridView, ListView and DetailView.)

While both yii2-app-advanced and yii2-app-basic templates use Bootstrap as their css framework, it is not a core component of Yii 2. You may do without it if you want it.

You can always write your own javascripts when you need them, usually in the view script using yii\web\View::registerJs(). Since jQuery is integrated in Yii, you’ll find yourself comfortable writing scripts using it.

Guide > Displaying Data > Working with Client Scripts


Take your time generously to examine what Yii can do for you. Don’t make a haste :)