Many newcomers to Yii ask about the assets/
directory found under the webroot, and this article means to explain why it's there and how to work with it.
Many newcomers to Yii ask about the assets/
directory found under the webroot, and this article means to explain why it's there and how to work with it.
When you define or extend a class, you can create class variables and methods in Yii just like you can in any other PHP system:
class Comment extends CActiveRecord {
public $helperVariable;
public function rules() { ... }
...
}
and then use them in the obvious way:
$var = $model->helperVariable;
$rules = $model->rules();
This part everybody understa...
Cookie management in Yii is easy, but may not be so obvious for the beginners to this framework, so I wrote this simple article to clear some doubts out.
A common source of confusion among new Yii users is how the 'safe'
validator works, how it works with other validators, and why it's necessary in the first place. This article means to clear up this confusion, as well as explain the notion of Massive Assignment.
This page intends to provide an exhaustive guide of how to use Javascript (JS) in Yii. It does not explain how to learn coding in JS, but how to deal with it "the Yii way".
Scenarios are an extremely useful tool for separating validation tasks on any class you use derived from CModel. In this tutorial we will use CActiveRecord.
There are many ways to automate the setting of timestamps in yii ActiveRecord models. Three are presented here:
Update: This wiki has been rewritten to be in line with Yii 1.1.14. Since many of the detailed complexities are now handled by Yii, the article focuses on how the crypt()
built-in function works and why it's important to use it correctly.
We start slowly and simple...
If you have to display a overview of related data in a table, you can use the CListView, create your view with table/tr/td tags and implement db-queries in the view to display detaildata of the current (master-)record.
hi guys, Here I'm going to give you a working example of ajax form submiting in Yii.
In this tutorial we will learn how to realize a create interface using a dialog.
It's very common to see new Yii users confusing the relations HAS_ONE
and BELONGS_TO
, and getting it wrong means you won't get proper values back. And though we'll talk about HAS_MANY
as well, we're specifically omitting the MANY_MANY
relation because it's a whole different animal.
These features provide endless possibilities and unbelievable flexibility, but as current documentation does not give more than a few examples, it might be difficult to fully understand their internals and requirements.
Ctrl+Space
.Ctrl+Q
.This little tutorial explains a way how you can retrieve more parameters from Yii::app()->user by adding a component that extends CWebUser and retrieves the user information from database table named User.
Sometimes the right place to store application data is in a join table. For example, movie viewers either like or don’t like the movies they watched.
Occasionally one wishes to set systemwide parameters for an application, such as a contact address for email, an application name, or setting an option that guides major behavior. Yii provides for setting of static parameters in the configuration file, and this article talks about how to do it conveniently.
The customary configuration of a Yii application includes just a single database section in the protected/config/main.php
file, but it's easy to extend this to support more than one, tying each Model to one of the databases.
Validators extending from [CValidator] all have a property named [message|CValidator::message]. You can set this property in the corresponding validation rule to customize the error message. For example, the following validation rule uses an error message that is different from the default one: