Wiki articles

Showing 1-20 of 822 items.

Guidelines for good schema design

Created 12 years ago by Steve Friedl, updated 5 years ago by softark.

Virtually all Yii applications are built on top of a database, and though Yii is very flexible in how it addresses your DB, some design choices make things more convenient than others.

124 0
71 followers
Viewed: 121 332 times
Version: 1.1
Category: Tips

Reference: Model rules validation

Created 14 years ago by krillzip, updated 10 years ago by Rodrigo.

This is a reference to be used for Model rule validation and is compiled from the Yii documentation and code. The purpose is to have all the information gathered in one place instead of scattered. This reference is not an intro. See The Definitive Guide to Yii, Declaring Validation Rules for a tutorial.

99 0
114 followers
Viewed: 884 297 times
Version: 1.1
Category: How-tos

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

Created 15 years ago by qiang, updated 11 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: 331 861 times
Version: 1.1
Category: Tutorials

How to write secure Yii1 applications

Created 12 years ago by François Gannaz, updated 2 years ago by François Gannaz.
  • Validate the user input (see below for details).
  • Protect (escape) your application output according to context (see below for a few output types, mostly HTML and SQL).
  • Test your application in debug mode.
    Set the constant YII_DEBUG to true (by default, it is defined in index.php) and put alongside error_reporting(E_ALL);. Then errors and warnings will stop the execution an...
80 0
114 followers
Viewed: 309 520 times
Version: 1.1
Category: How-tos

By Example: CHtml

Created 14 years ago by jonah, updated 7 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: 989 450 times
Version: 1.1
Category: Tutorials

Searching and sorting by related model in CGridView

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

Lets say we have two models and relation between them:

77 0
93 followers
Viewed: 271 900 times
Version: 1.1
Category: Tutorials

The directory structure of the Yii project site

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

In this article, we describe the directory structure used by yiiframework.com - the official Yii framework website. While this structure may look overly complicated for small projects or may not be optimal in some sense, we believe it is appropriate for medium or large projects in a team development environment. In fact, we have successfully used the similar structure in some other big projects.

77 0
96 followers
Viewed: 244 928 times
Version: 1.1
Category: Others

Using CButtonColumn to customize buttons in CGridView

Created 13 years ago by Trejder, updated 11 years ago by Gismo.

The easiest way to customize look and behaviour of them is to use series of CButtonColumn properties, like: updateButtonImageUrl (path to image for update button), updateButtonLabel (label for the update button; not HTML-encoded), updateButtonOptions (HTML options for this button, used in the way as many htmlOptions property for many widgets) and updateButtonUrl (a PHP expresion th...

75 0
59 followers
Viewed: 344 517 times
Version: 1.1
Category: How-tos

Understanding "Safe" Validation Rules

Created 13 years ago by Steve Friedl, updated 11 years ago by Gismo.

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.

75 0
46 followers
Viewed: 181 571 times
Version: 1.1
Category: FAQs

Yii for beginners

Created 12 years ago by rackycz, updated 4 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: 437 451 times
Version: 1.1
Category: Tutorials

Understanding Virtual Attributes and get/set methods

Created 12 years ago by Steve Friedl, updated 12 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: 202 282 times
Version: 1.1
Category: Tutorials

NetBeans IDE and Yii projects

Created 13 years ago by marcovtwout, updated 9 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: 248 480 times
Version: 1.1
Category: Tutorials

Create your own Validation Rule

Created 12 years ago by nickcv, updated 11 years ago by Gismo.

Some times the core validation rules provided by Yii won't satisfy all your needs, so you'll need to create your very own validation rule.

59 0
54 followers
Viewed: 272 172 times
Version: 1.1
Category: How-tos

Relations: BELONGS_TO versus HAS_ONE

Created 12 years ago by Steve Friedl, updated 10 years ago by Jorgee.

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.

56 0
35 followers
Viewed: 162 869 times
Version: 1.1
Category: FAQs

CJuiDialog to create new model

Created 13 years ago by zaccaria, updated 7 years ago by Maurizio Domba Cerin.

In this tutorial we will learn how to realize a create interface using a dialog.

55 0
64 followers
Viewed: 127 534 times
Version: 1.1
Category: Tutorials

CGridView: Render customized/complex datacolumns

Created 12 years ago by Joblo, updated 11 years ago by Joblo.

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.

53 0
74 followers
Viewed: 168 067 times
Version: 1.1
Category: Tips
Tags: CGridView

How-To: Create a REST API

Created 12 years ago by jwerner, updated 9 years ago by Rohit Suthar.

This article will explain how to create a REST API with the Yii framework.

98 2
123 followers
Viewed: 473 520 times
Version: 1.1
Category: How-tos

How to work with flash messages

Created 15 years ago by pfth, updated 12 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: 385 884 times
Version: 1.1
Category: Tutorials

Displaying, Sorting and Filtering Model Relations on a GridView

Created 9 years ago by Antonio Ramirez, updated 9 years ago by Antonio Ramirez.

One of the things you will find tricky to implement is the the sorting and filtering of a GridView's column that displays related model data.

48 0
37 followers
Viewed: 325 970 times
Version: 2.0
Category: How-tos

Getting to Understand Hierarchical RBAC Scheme

Created 13 years ago by daemons, updated 9 years ago by rAWTAZ.

Authentication and Authorization is a good tutorial. Among other topics, it describes basic aspects of Yii's RBAC implementation. But however hard I read the tutorial, I couldn't understand how exactly the hierarchy works. I found how to define authorization hierarchy, how business rules are evaluated, how to configure a...

47 0
56 followers
Viewed: 125 456 times
Version: 1.1
Category: Tutorials