Wiki

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

Using updateAll and deleteAll with scopes

Created 5 months ago by le_topHow-tos4 comments – viewed 6,358 times – ( +5 ) – version 1.1
Using CActiveRecord->updateAll() and CActiveRecord->deleteAll() with scopes and criteria requires some tricks that are explained in this article. While findAll() , find() and some other methods use scopes automatically, updateAll() and deleteAll() do not.

Alternative folder structure for a standard Yii app

Created about a year ago by TrejderHow-tos4 comments – viewed 9,017 times – ( +5 ) – version 1.1
I found a standard Yii app's protected folder structure nearly perfect. With a few simple moves and a little bit change to the code, I managed to bring it to the level, which I found as fully perfect. I want to share my point of view, in case someone would like to use this structure as well.

Client-side form validation using Twitter Bootstrap's Popovers

Created about a year ago by TrejderHow-tos4 comments – viewed 29,510 times – ( +4 / -1 ) – version 1.1
This article explains how to easily turn standard text-line validation errors into beautifully and professionally looking Twitter Bootstrap's Popovers.

defaultScope

Created about a year ago by Gerhard LiebenbergHow-tos4 comments – viewed 12,896 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 3 months ago by Antonio RamirezHow-tos4 comments – viewed 2,962 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,845 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,807 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 3 years ago by waitforitHow-tos3 comments – viewed 19,068 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 25,423 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,630 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.