Categories
YII

How to create custom widget in Yii2

This tutorial will show you how you can create your own custom widget in Yii2. Widgets are reusable blocks and they are used in your views. The main advantage of Widget is you can write once and reuse it wherever you need it in your view. To create a custom widget we must extend the […]

Categories
YII

Yii2 – GridView set default sort column

This tutorial will teach you, setting default specific sort column for your GridView. With the following code, you can set the specific column as default sorting column. Possible sorting options are SORT_DESC and SORT_ASC. Change ‘columnName’ to the name of the column to be sorted by.

Categories
YII

How to send e-mail from YII2 Application

Hi there, This tutorial will show you how to send emails from the yii2 application. Sending emails from the yii2 application is not a tedious task, in fact, we just need to edit/add the config options in your config file. Yii2 providing a flexible interface for send emails, however, to send emails we have to […]

Categories
YII

How to use mPDF In Yiiframework 2

Hello there, Today I would like to show you how to integrate mPDF library with Yii framework 2.First, let me give you some basic information about mPDF. mPDF is a PHP Class by using this we can easily generate PDF files from HTML templates so you can style your HTML template as you wish. Here […]

Categories
YII

How to create custom Component in Yii2

Hi there, Today I would like to write a simple tutorial on creating custom Component in Yii2 and I will show you how to use created a component in your application. Here are the simple steps, just follow the step at the end you will have your first custom component. Step1: Make a folder named […]

Categories
YII

Yii2 Transaction

In this tutorial, I would like to show you how we can use transactions in YII2. A transaction is used to run a group of operations in the single process means a transaction is a unit of work. Why should I use transaction? In database we may need to perform add, update or delete operations […]

Categories
YII

How to make a drop down list in yii2?

In this tutorial, I would like to show you making the dropdown list in yii2 using different data sources like static array data and database table modal data. First I would like to share basic syntax – here you go… Yii2 DropDownList syntax – active field style Yii2 DropDownList syntax – active form style Both […]

Categories
YII

How to remove index.php from URL in Yii2

To remove the index.php, create a file called .htaccess at the root/web/ of your YII2 site. You can find out more about .htaccess here, but for our purposes here we just want to use it to hide index.php in our URLs. Not every web server is the same, but something along these lines should work […]

Categories
YII

How to change app name in Yii2

Yii2 Default application name is “My Application”. You can change this name by editing the config/main.php. Just add the application name property in Config Array. NOTE: If you’re using the advanced app you will need to change the frontend and backbend config/main.php files. You can access site or app name with Yii::$app->name. Ref: http://www.yiiframework.com/doc/api/1.1/CApplication#name-detail

Categories
YII

How to make a drop down list in yii2

In this post, I would like to show you how to create a drop-down list in yii2. This tutorial will help you to display the array data or model data in the drop-down list. I am using activeForm. Drop down list syntax Drop down list with Array Drop down list with prompt Drop down list […]

Categories
YII

How to modify data before saving it into database in yii?

we sometimes need to modify user submitted data or based on user submitted data we need to do some calculation to fetch the values then, we will save that data in the database, so in order to achieve this, we will use modal events in YII. For example, you might want to do API requests […]

Categories
YII

How to display image in CGridView in YII

This post is a simple example for showing images in CGridView in Yii.Imagine that you have an image field in your table ie either a location field or a blob type field used to store the images.

Categories
YII

Yii Tutorial : How to Add JavaScript into your views ?

This post is about registering inline and external javascript files into views, Yii provided CClientScript to manage the scripts and CSS files in Yii application. How to Register or add External java script files : Here Script file located at webroot/resources/js., Yii::app()->baseUrl will return app base url. How to Register or add inline java script: […]

Categories
YII

Yii Tutorial :: How to Add Facebook Open Graph Tags ?

This Blog post is about Adding Facebook Open Graph Tags to the web app in Yii, This is really simple Task, Using This Tags We can tell Facebook What Content Should share like Image, Title, Description .. etc. Syntax How to Use You can place Above lines in views Files or in you Controller File […]

Categories
YII

How to add Date Picker to a Form Text Field in YII?

Here is simple code snippet for adding date picker in YII. We have a Date Picker widget in Yii so I am gonna show you how to use this widget with simple blow code sample. For more options visit : http://www.yiiframework.com/doc/api/1.1/CJuiDatePicker