Wiki

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

Easy way to redirect http:\\localhost\yii2-basic to http:\\localhost\yii2-basic\web\index.php

Created about 9 hours ago by Scott_HuangTips0 comments – viewed 405 times – version 2.0
First of all, install yii2 basic template according below link:

Add model validator in Controller

Created 8 days ago by KonApazTips4 comments – viewed 1,008 times – ( +1 / -1 ) – version 1.1
There are cases that model validators should be depended by controller/action and you couldn't manipulate on the model class or using scenarios in easy way

Step by step for how to full export Yii2 grid to excel

Created 9 days ago by Scott_HuangTips2 comments – viewed 1,146 times – version 2.0
We will leverage Yii2-excelview widget. So, first of all is install Yii2-excelview:

Create Form With DynamicModel

Created 13 days ago by Misbahul D MunirTips2 comments – viewed 1,294 times – version 2.0
In yii2 we can create form without create FormModel. Here we go
tags: form, yii2, model

embedded javascript block in your view with IDE checking or intellisense

Created about a month ago by yiqing95Tips0 comments – viewed 1,708 times – ( +3 ) – version 2.0
this is my way for embed js code block in view file:

Expert's model generation with Gii

Created 3 months ago by le_topTips0 comments – viewed 3,051 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 3 months ago by le_topTips1 comment – viewed 1,888 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 4 months ago by rafaelt88Tips1 comment – viewed 2,157 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 5 months ago by Kartik VTips0 comments – viewed 2,182 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 5 months ago by KonApazTips0 comments – viewed 2,767 times – ( +1 ) – version 1.1
There are cases that you want to make an ajax request to another server and get the results.