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:
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:
"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.
Lets say we have two models and relation between them:
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.
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...
This page is created to supply short directions and general tips for managing a Yii application in NetBeans IDE.
In this tutorial we will learn how to realize a create interface using a dialog.
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.");
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...
Because Yii intends to be integrated nicely with third-party libraries, it does not define any global functions. Everything in Yii needs to be addressed with full class name or object scopes. For example, to access the current user, we need to use Yii::app()->user
; to access application parameters, we need Yii::app()->params['name']
; and so on. While editors like textmate
can help alleviate...
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.
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.
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.
The easiest way to update content in AJAX is to use the renderPartial method.
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.
In this article, we introduce a set of CSS naming conventions that we have applied in several big projects and achieved success. The goal of these naming conventions is to eliminate the possibility of naming conflicts, facilitate debugging and maintenance, and to simplify the naming process.
You have a multilingual application, and you want the URL of a page to be different for different languages, to account for SEO. The URL for the contact page for example should look like http://something.com/en/contact in english, and http://something.com/de/contact in german. This tutorial describes how to make it happen.
Note that currently selected language is always a part...
This wiki describes a more complex workflow using the XUpload widget
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.
When creating web-application projects, you can add a great variety of different extensions, modules, plugins or scripts to your code-base. But maintaining a stable combination and updating certain packages can become a hard task.