Wiki articles

Showing 1-20 of 799 items.

By Example: CHtml

Created 9 years ago by jonah, updated 3 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.

78 0
74 followers
Viewed: 917 702 times
Version: 1.1
Category: Tutorials

Reference: Model rules validation

Created 9 years ago by krillzip, updated 5 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.

97 0
115 followers
Viewed: 811 861 times
Version: 1.1
Category: How-tos

How to upload a file using a model

Created 10 years ago by qiang, updated 4 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.

65 4
64 followers
Viewed: 479 207 times
Version: 1.1
Category: Tutorials

How-To: Create a REST API

Created 8 years ago by jwerner, updated 4 years ago by Rohit Suthar.

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

97 2
126 followers
Viewed: 405 912 times
Version: 1.1
Category: How-tos

Creating a dependent dropdown

Created 10 years ago by dalip, updated 4 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: 355 753 times
Version: 1.1
Category: Tutorials

Yii for beginners

Created 7 years ago by rackycz, updated 5 years ago by WaldemarPross.

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

67 0
75 followers
Viewed: 330 530 times
Version: 1.1
Category: Tutorials

How to work with flash messages

Created 10 years ago by pfth, updated 7 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.");
50 0
41 followers
Viewed: 326 986 times
Version: 1.1
Category: Tutorials

Using CButtonColumn to customize buttons in CGridView

Created 8 years ago by Trejder, updated 6 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
60 followers
Viewed: 315 552 times
Version: 1.1
Category: How-tos

Update content in AJAX with renderPartial

Created 9 years ago by Burzum, updated 7 years ago by hairylunch.

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

43 0
47 followers
Viewed: 284 511 times
Version: 1.1
Category: Tutorials
Tags: AJAX

Multiple files uploader with CMultiFileUpload

Created 5 years ago by Interboy, updated 5 months ago by samdark.

Today I will show you how to handle multiple file upload step by step.

4 0
8 followers
Viewed: 272 862 times
Version: 1.1
Category: How-tos

How to write secure Yii applications

Created 7 years ago by François Gannaz, updated 5 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
117 followers
Viewed: 264 062 times
Version: 1.1
Category: How-tos

Displaying, Sorting and Filtering Model Relations on a GridView

Created 5 years ago by Antonio Ramirez, updated 5 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.

28 0
30 followers
Viewed: 244 524 times
Version: 2.0
Category: How-tos

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

Created 10 years ago by qiang, updated 7 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:

87 0
78 followers
Viewed: 233 995 times
Version: 1.1
Category: Tutorials

Create your own Validation Rule

Created 8 years ago by nickcv, updated 6 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.

58 0
53 followers
Viewed: 227 313 times
Version: 1.1
Category: How-tos

Url: hide index.php

Created 8 years ago by Hermans, updated 8 years ago by Hermans.

Maybe it looks simple, but some time ago I need some time to find a solution of this case. I finally got it, and I want to share that I also experienced such cases. So that it can make reference.

19 0
31 followers
Viewed: 226 992 times
Version: 1.1
Category: How-tos

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

Created 6 years ago by Charles R. Portwood II, updated 5 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: 220 168 times
Version: 2.0
Category: Tutorials

Searching and sorting by related model in CGridView

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

Lets say we have two models and relation between them:

76 0
96 followers
Viewed: 219 646 times
Version: 1.1
Category: Tutorials

Understanding the view rendering flow

Created 7 years ago by dckurushin, updated 6 years ago by Jorgee.

If we take a look at the blog demo we have 3 major parts of our view rendering. They are:

56 1
55 followers
Viewed: 218 988 times
Version: 1.1
Category: FAQs

NetBeans IDE and Yii projects

Created 8 years ago by marcovtwout, updated 4 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: 215 066 times
Version: 1.1
Category: Tutorials

The directory structure of the Yii project site

Created 8 years ago by qiang, updated 6 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.

76 0
97 followers
Viewed: 206 736 times
Version: 1.1
Category: Others