Wiki

Articles in category "how-tos", sorted by commentsX
Displaying 121-130 of 320 result(s).

defaultScope

Created about a year ago by Gerhard LiebenbergHow-tos4 comments – viewed 12,522 times – ( +5 / -1 ) – version 1.1
This example includes a composite condition as well as an empty condition - as if you bypass or disable defaultScope without using resetScope().

How to implement form events

Created 2 months ago by Antonio RamirezHow-tos4 comments – viewed 2,727 times – ( +5 ) – version 2.0
You have that, when a product is on development they can change its API anytime. This change is quite important though, its related on how to set the events of your form, for example, the useful beforeSubmit.
tags: yii2, forms, how to

Use CGridview to sort and filter CSqlDataProvider - when used with UNRELATED tables (or complex queries)

Created about a month ago by Gerhard LiebenbergHow-tos4 comments – viewed 1,470 times – version 1.1
I have two tables called hospitals and departments. I have a junction table between them which holds the departments in each hospital. But sometimes I need a list of "All hospitals with All possible departments" - regardless of whether they are linked in the junction table or not.

How to re enable logging during unit testing

Created 3 years ago by AsgarothHow-tos3 comments – viewed 11,679 times – ( +11 ) – version 1.1
Some of you have experienced the need to log some information while doing unit testing, due to the fact that the information given in the summary is just not enough, to know why the test is actually failing. this article focuses on 2 ways to get you logs up and running again.

Secure password hashing with bCrypt

Created 2 years ago by waitforitHow-tos3 comments – viewed 18,849 times – ( +9 ) – version 1.1
In this article I will show you how to implement a secure password hashing mechanism in your Yii projects using a bCrypt class.

Drop down list with enum values for column of type ENUM >+> incorporate into giix

Created 2 years ago by c@cbaHow-tos3 comments – viewed 24,988 times – ( +14 ) – version 1.1
Let's say our table 'mug' has a column named 'color' of the type ENUM('red','green','blue'). We want to replace the textfield for the attribute color in the create and update forms of a 'mug' with a drop down list, which has the enum values as options. The main code was contributed by zaccaria in the forum (see this post).

How to extend CFormatter, add i18n support to booleanFormat and use it in CDetailView

Created 2 years ago by c@cbaHow-tos3 comments – viewed 9,520 times – ( +9 ) – version 1.1
As you know, the CDetailView widget displays details of a single model. If no formatting is specified, boolean values that are stored in the database as 0 and 1, are represented in the detail view as 0 and 1. If formatted as boolean, they are represented as 'No' and 'Yes'. We want to add i18n support, so that Yes and No appear in the current language.

i18n All-in-one format and timezone conversions for date, time, timestamp and datetime.

Created about a year ago by Gerhard LiebenbergHow-tos3 comments – viewed 12,164 times – ( +7 / -1 ) – version 1.1
Countries sometimes change their laws pertaining to timezones and daylight saving times. This means that GMT+2 can be a different time this August compared to last August! However, by using php's DateTime class (instead of timestamps), we can do both "format" and "timezone" conversions on a single DateTime object (only 2 lines of code) for date, time, timestamp and datetime types - while php takes care of nightmares such as current and historical timezones and daylight saving times.

Remove Byte Order Mark (BOM) from files recursively

Created about a year ago by KonApazHow-tos3 comments – viewed 6,000 times – ( +5 / -1 ) – version all
Ok, this wiki is not only for yii projects.

Using loginRequiredAjaxResponse to solve ajax session timeout

Created 2 years ago by RutgerHow-tos3 comments – viewed 19,129 times – ( +12 ) – version 1.1
This solution requires Yii 1.1.9 or above