Wiki

Articles in category "tips", sorted by commentsX
Displaying 31-40 of 149 result(s).

Adding a date range search for CGridView the easy way

Created 2 years ago by mikewalenTips5 comments – viewed 22,022 times – ( +12 ) – version 1.1
After a lot of research, everything I found on adding date range searching to a CGridView advanced search form seemed to involve adding two new public variables (e.g. $date_from, $date_to), 'safe' rules for the new variables, and a rather chunky if/elseif/else check in the search() method. This probably isn't a hassle for most, but because many of the tables in my database contain two or three and sometimes four date columns (e.g. date_created, date_modified, date_deleted etc.), it meant I was having to add up to eight public variables, the corresponding safe rules, and modifying the search() criteria for each date attribute. So, I set about creating a better way and I thought I'd share my work with the community.

Managing constants easily

Created 3 years ago by briiC.lvTips4 comments – viewed 12,282 times – ( +4 ) – version 1.1
For time to time i have models with constants (basicly status constants) which i use in diferent places and if these constant changes, i have to change mentions of constant in code elsewhere.

using multiple radio button

Created 3 years ago by francis jaTips4 comments – viewed 37,293 times – ( +9 / -1 ) – version 1.1
When we use multiple radio buttons with same name in Yii many people have the problem on getting the value of the selected radiobutton. The radioButtonList can be used for that, but if we need to use radioButton itself to place the button any where in a view, we need to include one more parameter in htmloption array().

Rendering Views and Updating them with Ajax

Created about a year ago by Manish GuptaTips4 comments – viewed 16,483 times – ( +2 )
I wanted to implement a widget that could refresh itself through Ajax without refreshing the whole page. CGridView and CListView are excellent examples of such widgets.

Customize CGridView columns directly in your view

Created 2 years ago by clapasTips4 comments – viewed 25,192 times – ( +3 / -2 ) – version 1.1
You usually take a model instance passed into your view to provide data to a CGridView in this way:

Send asset folder path to a javascript of a widget

Created 3 years ago by sensorarioTips4 comments – viewed 19,175 times – ( +4 ) – version 1.1
When you develop a widget, you could need one image that is in the assets folder, you can use it simply within a css. You can load a css or javascript script doing this:

Using CListView to display items next to each other (in columns)

Created 2 years ago by thyseusTips4 comments – viewed 10,771 times – ( +11 )
When using CListView to display multiple views next to each other, we can use the $index variable inside the viewFile to achieve this. As far as i know there is no extension or out-of-the-box functionality for this, so we need to apply a little hack:

Shrink Yii, help your IDE and speed up copying

Created 3 years ago by dckurushinTips4 comments – viewed 9,235 times – ( +10 / -9 ) – version 1.1
In this little tip, I will help you to cut Yii size for about half

how to use github (un)official extension repo in your Yii project

Created 3 years ago by RusAlexTips4 comments – viewed 7,709 times – ( +4 ) – version 1.1
Using a git submodule command in your yii project

Create Form With DynamicModel

Created 9 months ago by Misbahul D MunirTips4 comments – viewed 4,123 times – version 2.0
In yii2 we can create form without create FormModel. Here we go
tags: form, yii2, model