Wiki

Articles in category "tips"X
Displaying 1-10 of 134 result(s).

Expert's model generation with Gii

Created 2 months ago by le_topTips0 comments – viewed 2,513 times – ( +3 ) – version 1.1
Efficient coding with Yii implies efficient use of the code generator. This article shares the personalised Gii templates that were built starting from the standard templates proposed by AweGen.

Search scenario (CGridView, etc.): avoid default values from database as search condition.

Created 2 months ago by le_topTips1 comment – viewed 1,526 times – ( +1 ) – version 1.1
Yii has a neat "trick" that will assign default values to new CActiveRecords. When performing a search() though, this is pretty annoying as they automatically apply as filter values.

View a related field in CGridView

Created 2 months ago by rafaelt88Tips1 comment – viewed 1,569 times – ( +5 ) – version 1.1
Generally we need to show one or more fields from a model that is related to another model used in CGridView. For our case we will use two related models, which explain how to use model "A" fields in a CGridView that used model "B".

Model validation for field ranges using yii2-field-range extension

Created 4 months ago by Kartik VTips0 comments – viewed 1,646 times – ( +29 ) – version 2.0
The yii2-field-range extension enables you to easily setup ActiveField range fields with Bootstrap styling. You basically can setup two attributes joined together like a single field with combined validation error block.

Make an ajax request to another server using JSONP

Created 4 months ago by KonApazTips0 comments – viewed 2,286 times – ( +1 ) – version 1.1
There are cases that you want to make an ajax request to another server and get the results.

Key web server settings after installing a fresh Yii 2 basic or advanced app

Created 4 months ago by Kartik VTips0 comments – viewed 1,984 times – ( +29 ) – version 2.0
So, you have installed a brand new Yii 2 app (basic) or (advanced). Here are a few tips for Apache web server users to get things running more secure and better with your yii2 app.

Create URL to language switcher anchor with langhandler

Created 4 months ago by Anas AbuDayahTips2 comments – viewed 1,230 times – ( +1 / -1 ) – version 1.1
This topic is related with langhandler extension

Install specific Yii2 vendor extension & dependency without updating other packages.

Created 4 months ago by Kartik VTips0 comments – viewed 1,405 times – ( +30 / -5 ) – version 2.0
The tips here are for advanced usages of composer and its assumed you have read about using composer and have a knowledge of your vendor packages to be updated. Let's consider, you want to update only one specific yii2 vendor library, without updating all the other extension packages?

Locking your Yii 2 project package versions with composer.lock

Created 4 months ago by Kartik VTips0 comments – viewed 1,168 times – ( +28 / -4 ) – version 2.0
Ok, you have installed a Yii 2 basic or advanced app for the first time and completed the post install steps. You have picked up a few extensions to install for the first time as well. You would already see a composer.lock file in your application root folder.

My Own Components Folder in Yii2

Created 4 months ago by CTalaTips0 comments – viewed 1,835 times – ( +3 / -1 ) – version 2.0
In Yii1 I used to have my own components under the components folder of the structure, now with namespacing this is a little bit different.