Wiki articles

Showing 1-20 of 651 items.

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 449 times
Version: 1.1
Category: Tutorials

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 295 times
Version: 1.1
Category: How-tos

How to upload a file using a model

Created 15 years ago by qiang, updated 8 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: 516 617 times
Version: 1.1
Category: Tutorials

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 518 times
Version: 1.1
Category: How-tos

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 448 times
Version: 1.1
Category: Tutorials

Creating a dependent dropdown

Created 15 years ago by dalip, updated 9 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: 411 796 times
Version: 1.1
Category: Tutorials

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 879 times
Version: 1.1
Category: Tutorials

Update content in AJAX with renderPartial

Created 14 years ago by Burzum, updated 11 years ago by hairylunch.

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

43 0
46 followers
Viewed: 351 685 times
Version: 1.1
Category: Tutorials
Tags: AJAX

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 516 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 518 times
Version: 1.1
Category: How-tos

Multiple files uploader with CMultiFileUpload

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

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

5 0
8 followers
Viewed: 281 015 times
Version: 1.1
Category: How-tos

Url: hide index.php

Created 12 years ago by Hermans, updated 12 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: 277 612 times
Version: 1.1
Category: How-tos

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 171 times
Version: 1.1
Category: How-tos

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

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 479 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 927 times
Version: 1.1
Category: Others

Understanding the view rendering flow

Created 12 years ago by dckurushin, updated 10 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: 239 717 times
Version: 1.1
Category: FAQs

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

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

How to upload image(photo), and path entry in database with update functionality

Created 11 years ago by kiran sharma, updated 10 years ago by Shahcheraghean.

I saw many posts that community newbie is confuse in image/photo upload with random name. so I post this topic covering all useful things regarding to image/photo upload(not covering image attribute related functionality)

15 0
39 followers
Viewed: 209 857 times
Version: 1.1
Category: Tips