Wiki

Articles in category "tips"X
Displaying 11-20 of 147 result(s).

Add model validator in Controller

Created 6 months ago by Kostas Apazidis (KonApaz)Tips4 comments – viewed 4,736 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 6 months ago by Scott_HuangTips2 comments – viewed 7,482 times – version 2.0
We will leverage Yii2-excelview widget. So, first of all is install Yii2-excelview:

Create Form With DynamicModel

Created 6 months ago by Misbahul D MunirTips4 comments – viewed 3,426 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 7 months ago by yiqing95Tips0 comments – viewed 2,495 times – ( +3 ) – version 2.0
this is my way for embed js code block in view file:

Expert's model generation with Gii

Created 9 months ago by le_topTips0 comments – viewed 4,658 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 9 months ago by le_topTips1 comment – viewed 2,777 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 10 months ago by rafaelt88Tips1 comment – viewed 4,934 times – ( +6 ) – 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 11 months ago by Kartik VTips0 comments – viewed 4,779 times – ( +36 ) – 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 11 months ago by Kostas Apazidis (KonApaz)Tips0 comments – viewed 4,069 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 11 months ago by Kartik VTips2 comments – viewed 6,351 times – ( +43 ) – 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.