Wiki articles in category Tutorials

Showing 1-20 of 265 items.

By Example: CHtml

Created 15 years ago by jonah, updated 9 years ago by glicious.

"By Example" cookbook pages will provide coding examples for many of the commonly used classes within Yii. We will try to provide as many usage examples as possible for keep these pages as helpful as possible.

79 0
74 followers
Viewed: 998 428 times
Version: 1.1
Category: Tutorials

How to upload a file using a model

Created 16 years ago by qiang, updated 10 years ago by samdark.

First declare an attribute to store the file name in the model class (either a form model or an active record model). Also declare a file validation rule for this attribute to ensure a file is uploaded with specific extension name.

66 4
64 followers
Viewed: 522 905 times
Version: 1.1
Category: Tutorials

Yii for beginners

Created 13 years ago by rackycz, updated 5 years ago by rackycz.

Hi. This is first article with my Yii v1 tutorial. I had to split it into 2 articles as there's limited length of texts on Wiki. So once you understand basics, you can read the 2nd article here: Yii for beginners 2.

68 0
75 followers
Viewed: 449 166 times
Version: 1.1
Category: Tutorials

Creating a dependent dropdown

Created 16 years ago by dalip, updated 10 years ago by Paul_Kish.

Often you'll need a form with two dropdowns, and one dropdown's values will be dependent on the value of the other dropdown. Using Yii's built-in AJAX functionality you can create such a dropdown.

83 2
92 followers
Viewed: 421 909 times
Version: 1.1
Category: Tutorials

How to work with flash messages

Created 16 years ago by pfth, updated 13 years ago by François Gannaz.

Set your messages in a controller:

Yii::app()->user->setFlash('success', "Data1 saved!");
Yii::app()->user->setFlash('error', "Data2 failed!");
Yii::app()->user->setFlash('notice', "Data3 ignored.");
51 0
40 followers
Viewed: 394 261 times
Version: 1.1
Category: Tutorials

Update content in AJAX with renderPartial

Created 15 years ago by Burzum, updated 12 years ago by hairylunch.

The easiest way to update content in AJAX is to use the renderPartial method.

43 0
46 followers
Viewed: 367 308 times
Version: 1.1
Category: Tutorials
Tags: AJAX

How to use a single form to collect data for two or more models?

Created 16 years ago by qiang, updated 13 years ago by Yang He.

Assume we want to use a single HTML form to collect input for both model A and model B, and we want to display input errors (if any) in the same error summary box. We can define the following action code:

88 0
79 followers
Viewed: 358 716 times
Version: 1.1
Category: Tutorials

Creating a Simple CRUD App With Yii2 (Revised 12/20/2013)

Created 12 years ago by Charles R. Portwood II, updated 11 years ago by Vivek.

By popular demand, today I will be revisiting my previous Yii Framework 2 Getting Started Guide and updating it with what is currently available in the Yii Framework 2 Repository. Provide here is an super simple example CRUD application that will help you get started using the framework.

7 6
21 followers
Viewed: 312 890 times
Version: 2.0
Category: Tutorials
7 0
4 followers
Viewed: 312 161 times
Version: 2.0
Category: Tutorials

Searching and sorting by related model in CGridView

Created 13 years ago by Maciej Liżewski, updated 11 years ago by Kostas Apazidis (KonApaz).

Lets say we have two models and relation between them:

77 0
93 followers
Viewed: 279 724 times
Version: 1.1
Category: Tutorials

Filter & Sort by calculated/related fields in GridView Yii 2.0

Created 11 years ago by Kartik V, updated 6 years ago by softark.

This wiki explains how to add calculated fields into your Yii Framework 2.0 gridview with filtering and sorting.

14 3
64 followers
Viewed: 275 170 times
Version: 2.0
Category: Tutorials

NetBeans IDE and Yii projects

Created 14 years ago by marcovtwout, updated 10 years ago by marcovtwout.

This page is created to supply short directions and general tips for managing a Yii application in NetBeans IDE.

65 0
66 followers
Viewed: 255 167 times
Version: 1.1
Category: Tutorials

How to add more information to Yii::app()->user

Created 16 years ago by qiang, updated 13 years ago by Yang He.

By default, the expression Yii::app()->user returns a [CWebUser] [application component](http://www.yiiframework.com/doc/guide/basics.application#application-component) which represents the information that are closely related with the current user. Some information can be persistent throughout the current user session. For example, [CWebUser] already comes with a [name|CWebUser::name] property th...

21 0
28 followers
Viewed: 230 903 times
Version: 1.1
Category: Tutorials

Understanding "Assets"

Created 14 years ago by Steve Friedl, updated 13 years ago by GOsha.

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.

46 0
40 followers
Viewed: 212 919 times
Version: 1.1
Category: Tutorials

Yii v2 snippet guide III

Created 4 years ago by rackycz, updated a year ago by rackycz.

Articles are separated into more files as there is the max lenght for each file on wiki.

8 0
4 followers
Viewed: 212 794 times
Version: 2.0
Category: Tutorials

(draft) Understanding Yii 3

Created 6 years ago by Mehdi Achour, updated 3 years ago by samdark.

This document is intended for an audience already familiar with Yii2. It's meant to bring together all information related to Yii 3 in one place to make it easier to get on track.

40 0
17 followers
Viewed: 208 983 times
Version: 3.0
Category: Tutorials
Tags: yii3

Understanding Virtual Attributes and get/set methods

Created 14 years ago by Steve Friedl, updated 13 years ago by GOsha.

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...

66 0
44 followers
Viewed: 208 546 times
Version: 1.1
Category: Tutorials

How to automate timestamps in ActiveRecord models

Created 16 years ago by dalip, updated 13 years ago by Yang He.

There are many ways to automate the setting of timestamps in yii ActiveRecord models. Three are presented here:

26 0
34 followers
Viewed: 183 211 times
Version: 1.1
Category: Tutorials
Tags:

Understanding Scenarios

Created 13 years ago by Luke Jurgs, updated 12 years ago by Luke Jurgs.

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.

23 0
39 followers
Viewed: 183 110 times
Version: 1.1
Category: Tutorials

Use crypt() for password storage

Created 12 years ago by fsb, updated 10 years ago by fsb.

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.

15 0
20 followers
Viewed: 181 457 times
Version: 1.1
Category: Tutorials