Commit 8bf91847 by Carsten Brandt

edited the guid. fixed a huge bunch of links, hopefully all :)

parent 3846e5c3
...@@ -506,8 +506,8 @@ $order->subtotal = 100; ...@@ -506,8 +506,8 @@ $order->subtotal = 100;
$customer->link('orders', $order); $customer->link('orders', $order);
``` ```
The [[yii\db\Activerecord::link()|link()]] call above will set the `customer_id` of the order to be the primary key The [[yii\db\ActiveRecord::link()|link()]] call above will set the `customer_id` of the order to be the primary key
value of `$customer` and then call [[yii\db\Activerecord::save()|save()]] to save the order into database. value of `$customer` and then call [[yii\db\ActiveRecord::save()|save()]] to save the order into database.
Life Cycles of an ActiveRecord Object Life Cycles of an ActiveRecord Object
...@@ -520,33 +520,33 @@ method overriding and event handling mechanisms. ...@@ -520,33 +520,33 @@ method overriding and event handling mechanisms.
When instantiating a new ActiveRecord instance, we will have the following life cycles: When instantiating a new ActiveRecord instance, we will have the following life cycles:
1. constructor 1. constructor
2. [[yii\db\Activerecord::init()|init()]]: will trigger an [[yii\db\Activerecord::EVENT_INIT|EVENT_INIT]] event 2. [[yii\db\ActiveRecord::init()|init()]]: will trigger an [[yii\db\ActiveRecord::EVENT_INIT|EVENT_INIT]] event
When getting an ActiveRecord instance through the [[yii\db\Activerecord::find()|find()]] method, we will have the following life cycles: When getting an ActiveRecord instance through the [[yii\db\ActiveRecord::find()|find()]] method, we will have the following life cycles:
1. constructor 1. constructor
2. [[yii\db\Activerecord::init()|init()]]: will trigger an [[yii\db\Activerecord::EVENT_INIT|EVENT_INIT]] event 2. [[yii\db\ActiveRecord::init()|init()]]: will trigger an [[yii\db\ActiveRecord::EVENT_INIT|EVENT_INIT]] event
3. [[yii\db\Activerecord::afterFind()|afterFind()]]: will trigger an [[yii\db\Activerecord::EVENT_AFTER_FIND|EVENT_AFTER_FIND]] event 3. [[yii\db\ActiveRecord::afterFind()|afterFind()]]: will trigger an [[yii\db\ActiveRecord::EVENT_AFTER_FIND|EVENT_AFTER_FIND]] event
When calling [[yii\db\Activerecord::save()|save()]] to insert or update an ActiveRecord, we will have the following life cycles: When calling [[yii\db\ActiveRecord::save()|save()]] to insert or update an ActiveRecord, we will have the following life cycles:
1. [[yii\db\Activerecord::beforeValidate()|beforeValidate()]]: will trigger an [[yii\db\Activerecord::EVENT_BEFORE_VALIDATE|EVENT_BEFORE_VALIDATE]] event 1. [[yii\db\ActiveRecord::beforeValidate()|beforeValidate()]]: will trigger an [[yii\db\ActiveRecord::EVENT_BEFORE_VALIDATE|EVENT_BEFORE_VALIDATE]] event
2. [[yii\db\Activerecord::afterValidate()|afterValidate()]]: will trigger an [[yii\db\Activerecord::EVENT_AFTER_VALIDATE|EVENT_AFTER_VALIDATE]] event 2. [[yii\db\ActiveRecord::afterValidate()|afterValidate()]]: will trigger an [[yii\db\ActiveRecord::EVENT_AFTER_VALIDATE|EVENT_AFTER_VALIDATE]] event
3. [[yii\db\Activerecord::beforeSave()|beforeSave()]]: will trigger an [[yii\db\Activerecord::EVENT_BEFORE_INSERT|EVENT_BEFORE_INSERT]] or [[yii\db\Activerecord::EVENT_BEFORE_UPDATE|EVENT_BEFORE_UPDATE]] event 3. [[yii\db\ActiveRecord::beforeSave()|beforeSave()]]: will trigger an [[yii\db\ActiveRecord::EVENT_BEFORE_INSERT|EVENT_BEFORE_INSERT]] or [[yii\db\ActiveRecord::EVENT_BEFORE_UPDATE|EVENT_BEFORE_UPDATE]] event
4. perform the actual data insertion or updating 4. perform the actual data insertion or updating
5. [[yii\db\Activerecord::afterSave()|afterSave()]]: will trigger an [[yii\db\Activerecord::EVENT_AFTER_INSERT|EVENT_AFTER_INSERT]] or [[yii\db\Activerecord::EVENT_AFTER_UPDATE|EVENT_AFTER_UPDATE]] event 5. [[yii\db\ActiveRecord::afterSave()|afterSave()]]: will trigger an [[yii\db\ActiveRecord::EVENT_AFTER_INSERT|EVENT_AFTER_INSERT]] or [[yii\db\ActiveRecord::EVENT_AFTER_UPDATE|EVENT_AFTER_UPDATE]] event
Finally when calling [[yii\db\Activerecord::delete()|delete()]] to delete an ActiveRecord, we will have the following life cycles: Finally when calling [[yii\db\ActiveRecord::delete()|delete()]] to delete an ActiveRecord, we will have the following life cycles:
1. [[yii\db\Activerecord::beforeDelete()|beforeDelete()]]: will trigger an [[yii\db\Activerecord::EVENT_BEFORE_DELETE|EVENT_BEFORE_DELETE]] event 1. [[yii\db\ActiveRecord::beforeDelete()|beforeDelete()]]: will trigger an [[yii\db\ActiveRecord::EVENT_BEFORE_DELETE|EVENT_BEFORE_DELETE]] event
2. perform the actual data deletion 2. perform the actual data deletion
3. [[yii\db\Activerecord::afterDelete()|afterDelete()]]: will trigger an [[yii\db\Activerecord::EVENT_AFTER_DELETE|EVENT_AFTER_DELETE]] event 3. [[yii\db\ActiveRecord::afterDelete()|afterDelete()]]: will trigger an [[yii\db\ActiveRecord::EVENT_AFTER_DELETE|EVENT_AFTER_DELETE]] event
Custom scopes Custom scopes
------------- -------------
When [[yii\db\Activerecord::find()|find()]] or [[yii\db\Activerecord::findBySql()|findBySql()]] Active Record method is being called without parameters it returns an [[yii\db\Activerecord::yii\db\ActiveQuery|yii\db\ActiveQuery]] When [[yii\db\ActiveRecord::find()|find()]] or [[yii\db\ActiveRecord::findBySql()|findBySql()]] Active Record method is being called without parameters it returns an [[yii\db\ActiveRecord::yii\db\ActiveQuery|yii\db\ActiveQuery]]
instance. This object holds all the parameters and conditions for a future query and also allows you to customize these instance. This object holds all the parameters and conditions for a future query and also allows you to customize these
using a set of methods that are called scopes. By default there is a good set of such methods some of which we've using a set of methods that are called scopes. By default there is a good set of such methods some of which we've
already used above: `where`, `orderBy`, `limit` etc. already used above: `where`, `orderBy`, `limit` etc.
...@@ -657,8 +657,8 @@ When a few DB operations are related and are executed ...@@ -657,8 +657,8 @@ When a few DB operations are related and are executed
TODO: FIXME: WIP, TBD, https://github.com/yiisoft/yii2/issues/226 TODO: FIXME: WIP, TBD, https://github.com/yiisoft/yii2/issues/226
, ,
[[yii\db\Activerecord::afterSave()|afterSave()]], [[yii\db\Activerecord::beforeDelete()|beforeDelete()]] and/or [[yii\db\Activerecord::afterDelete()|afterDelete()]] life cycle methods. Developer may come [[yii\db\ActiveRecord::afterSave()|afterSave()]], [[yii\db\ActiveRecord::beforeDelete()|beforeDelete()]] and/or [[yii\db\ActiveRecord::afterDelete()|afterDelete()]] life cycle methods. Developer may come
to the solution of overriding ActiveRecord [[yii\db\Activerecord::save()|save()]] method with database transaction wrapping or to the solution of overriding ActiveRecord [[yii\db\ActiveRecord::save()|save()]] method with database transaction wrapping or
even using transaction in controller action, which is strictly speaking doesn't seem to be a good even using transaction in controller action, which is strictly speaking doesn't seem to be a good
practice (recall "skinny-controller / fat-model" fundamental rule). practice (recall "skinny-controller / fat-model" fundamental rule).
...@@ -686,7 +686,7 @@ class Product extends \yii\db\ActiveRecord ...@@ -686,7 +686,7 @@ class Product extends \yii\db\ActiveRecord
} }
``` ```
Overriding [[yii\db\Activerecord::save()|save()]] method: Overriding [[yii\db\ActiveRecord::save()|save()]] method:
```php ```php
......
...@@ -2,9 +2,9 @@ Managing assets ...@@ -2,9 +2,9 @@ Managing assets
=============== ===============
An asset in Yii is a file that is included into the page. It could be CSS, JavaScript or An asset in Yii is a file that is included into the page. It could be CSS, JavaScript or
any other file. Framework provides many ways to work with assets from basics such as adding `<script src="` tag any other file. Framework provides many ways to work with assets from basics such as adding `<script src="...">` tag
for a file that is [handled by View](view.md) section to advanced usage such as publishing files that are not for a file that is [handled by View](view.md) section to advanced usage such as publishing files that are not
under webserve document root, resolving JavaScript dependencies or minifying CSS. under the webservers document root, resolving JavaScript dependencies or minifying CSS.
Declaring asset bundle Declaring asset bundle
---------------------- ----------------------
...@@ -13,9 +13,15 @@ In order to publish some assets you should declare an asset bundle first. The bu ...@@ -13,9 +13,15 @@ In order to publish some assets you should declare an asset bundle first. The bu
directories to be published and their dependencies on other asset bundles. directories to be published and their dependencies on other asset bundles.
Both basic and advanced application templates contain `AppAsset` asset bundle class that defines assets required Both basic and advanced application templates contain `AppAsset` asset bundle class that defines assets required
application wide. Let's review basic application asset bundle class: application wide. An asset bundle class always extends from [[yii\web\AssetBundle]].
Let's review basic application's asset bundle class:
```php ```php
<?php
use yii\web\AssetBundle as AssetBundle;
class AppAsset extends AssetBundle class AppAsset extends AssetBundle
{ {
public $basePath = '@webroot'; public $basePath = '@webroot';
......
...@@ -209,7 +209,7 @@ public function behaviors() ...@@ -209,7 +209,7 @@ public function behaviors()
} }
``` ```
Another way is to call [[User::checkAccess()]] where appropriate. Another way is to call [[yii\web\User::checkAccess()]] where appropriate.
### Using DB-based storage for RBAC ### Using DB-based storage for RBAC
......
...@@ -5,21 +5,22 @@ Basic concepts of Yii ...@@ -5,21 +5,22 @@ Basic concepts of Yii
Component and Object Component and Object
-------------------- --------------------
Classes of the Yii framework usually extend from one of the two base classes [[Object]] and [[Component]]. Classes of the Yii framework usually extend from one of the two base classes [[yii\base\Object]] and [[yii\base\Component]].
These classes provide useful features that are added automatically to all classes extending from them. These classes provide useful features that are added automatically to all classes extending from them.
The `Object` class provides the [configuration and property feature](../api/base/Object.md). The [[yii\base\Object|Object]] class provides the [configuration and property feature](../api/base/Object.md).
The `Component` class extends from `Object` and adds [event handling](events.md) and [behaviors](behaviors.md). The [[yii\base\Component|Component]] class extends from [[yii\base\Object|Object]] and adds
[event handling](events.md) and [behaviors](behaviors.md).
`Object` is usually used for classes that represent basic data structures while `Component` is used for [[yii\base\Object|Object]] is usually used for classes that represent basic data structures while
application components and other classes that implement higher logic. [[yii\base\Component|Component]] is used for application components and other classes that implement higher logic.
Object Configuration Object Configuration
-------------------- --------------------
The [[Object]] class introduces a uniform way of configuring objects. Any descendant class The [[yii\base\Object|Object]] class introduces a uniform way of configuring objects. Any descendant class
of [[Object]] should declare its constructor (if needed) in the following way so that of [[yii\base\Object|Object]] should declare its constructor (if needed) in the following way so that
it can be properly configured: it can be properly configured:
```php ```php
......
...@@ -9,8 +9,10 @@ code execution. Unlike [PHP's traits](http://www.php.net/traits), behaviors can ...@@ -9,8 +9,10 @@ code execution. Unlike [PHP's traits](http://www.php.net/traits), behaviors can
Using behaviors Using behaviors
--------------- ---------------
A behavior can be attached to any class that extends from `Component`. In order to attach a behavior to a class, the component class must implement the `behaviors` A behavior can be attached to any class that extends from [[yii\base\Component]]. In order to attach a behavior to a class,
method. As an example, Yii provides the `AutoTimestamp` behavior for automatically updating timestamp fields when saving an Active Record model: the component class must implement the `behaviors`
method. As an example, Yii provides the [[yii\behaviors\AutoTimestamp|AutoTimestamp]] behavior for automatically updating timestamp
fields when saving an [[yii\db\ActiveRecord|Active Record]] model:
```php ```php
class User extends ActiveRecord class User extends ActiveRecord
...@@ -32,7 +34,10 @@ class User extends ActiveRecord ...@@ -32,7 +34,10 @@ class User extends ActiveRecord
} }
``` ```
In the above, the `class` value is a string representing the fully qualified behavior class name. All of the other key-value pairs represent corresponding public properties of the `AutoTimestamp` class, thereby customizing how the behavior functions. In the above, the `class` value is a string representing the fully qualified behavior class name.
All of the other key-value pairs represent corresponding public properties of the [[yii\behaviors\AutoTimestamp|AutoTimestamp]]
class, thereby customizing how the behavior functions.
Creating your own behaviors Creating your own behaviors
--------------------------- ---------------------------
......
...@@ -33,18 +33,18 @@ Yii widgets ...@@ -33,18 +33,18 @@ Yii widgets
Most complex bootstrap components are wrapped into Yii widgets to allow more robust syntax and integrate with Most complex bootstrap components are wrapped into Yii widgets to allow more robust syntax and integrate with
framework features. All widgets belong to `\yii\bootstrap` namespace: framework features. All widgets belong to `\yii\bootstrap` namespace:
- Alert - [[yii\bootstrap\Alert|Alert]]
- Button - [[yii\bootstrap\Button|Button]]
- ButtonDropdown - [[yii\bootstrap\ButtonDropdown|ButtonDropdown]]
- ButtonGroup - [[yii\bootstrap\ButtonGroup|ButtonGroup]]
- Carousel - [[yii\bootstrap\Carousel|Carousel]]
- Collapse - [[yii\bootstrap\Collapse|Collapse]]
- Dropdown - [[yii\bootstrap\Dropdown|Dropdown]]
- Modal - [[yii\bootstrap\Modal|Modal]]
- Nav - [[yii\bootstrap\Nav|Nav]]
- NavBar - [[yii\bootstrap\NavBar|NavBar]]
- Progress - [[yii\bootstrap\Progress|Progress]]
- Tabs - [[yii\bootstrap\Tabs|Tabs]]
Using the .less files of Bootstrap directly Using the .less files of Bootstrap directly
...@@ -52,7 +52,7 @@ Using the .less files of Bootstrap directly ...@@ -52,7 +52,7 @@ Using the .less files of Bootstrap directly
If you want to include the [Bootstrap css directly in your less files](http://getbootstrap.com/getting-started/#customizing) If you want to include the [Bootstrap css directly in your less files](http://getbootstrap.com/getting-started/#customizing)
you may need to disable the original bootstrap css files to be loaded. you may need to disable the original bootstrap css files to be loaded.
You can do this by setting the css property of the `BootstrapAsset` to be empty. You can do this by setting the css property of the [[yii\bootstrap\BootstrapAsset|BootstrapAsset]] to be empty.
For this you need to configure the `assetManagner` application component as follows: For this you need to configure the `assetManagner` application component as follows:
```php ```php
......
...@@ -73,7 +73,7 @@ is a summary of the available cache components: ...@@ -73,7 +73,7 @@ is a summary of the available cache components:
[Zend Data Cache](http://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm) [Zend Data Cache](http://files.zend.com/help/Zend-Server-6/zend-server.htm#data_cache_component.htm)
as the underlying caching medium. as the underlying caching medium.
Tip: because all these cache components extend from the same base class [[Cache]], one can switch to use Tip: because all these cache components extend from the same base class [[yii\caching\Cache]], one can switch to use
a different type of cache without modifying the code that uses cache. a different type of cache without modifying the code that uses cache.
Caching can be used at different levels. At the lowest level, we use cache to store a single piece of data, Caching can be used at different levels. At the lowest level, we use cache to store a single piece of data,
...@@ -92,9 +92,9 @@ Data Caching ...@@ -92,9 +92,9 @@ Data Caching
Data caching is about storing some PHP variable in cache and retrieving it later from cache. For this purpose, Data caching is about storing some PHP variable in cache and retrieving it later from cache. For this purpose,
the cache component base class [[\yii\caching\Cache]] provides two methods that are used most of the time: the cache component base class [[\yii\caching\Cache]] provides two methods that are used most of the time:
[[set()]] and [[get()]]. Note, only serializable variables and objects could be cached successfully. [[yii\caching\Cache::set()|set()]] and [[yii\caching\Cache::get()|get()]]. Note, only serializable variables and objects could be cached successfully.
To store a variable `$value` in cache, we choose a unique `$key` and call [[set()]] to store it: To store a variable `$value` in cache, we choose a unique `$key` and call [[yii\caching\Cache::set()|set()]] to store it:
```php ```php
Yii::$app->cache->set($key, $value); Yii::$app->cache->set($key, $value);
...@@ -102,7 +102,7 @@ Yii::$app->cache->set($key, $value); ...@@ -102,7 +102,7 @@ Yii::$app->cache->set($key, $value);
The cached data will remain in the cache forever unless it is removed because of some caching policy The cached data will remain in the cache forever unless it is removed because of some caching policy
(e.g. caching space is full and the oldest data are removed). To change this behavior, we can also supply (e.g. caching space is full and the oldest data are removed). To change this behavior, we can also supply
an expiration parameter when calling [[set()]] so that the data will be removed from the cache after an expiration parameter when calling [[yii\caching\Cache::set()|set()]] so that the data will be removed from the cache after
a certain period of time: a certain period of time:
```php ```php
...@@ -110,7 +110,7 @@ a certain period of time: ...@@ -110,7 +110,7 @@ a certain period of time:
Yii::$app->cache->set($key, $value, 45); Yii::$app->cache->set($key, $value, 45);
``` ```
Later when we need to access this variable (in either the same or a different web request), we call [[get()]] Later when we need to access this variable (in either the same or a different web request), we call [[yii\caching\Cache::get()|get()]]
with the key to retrieve it from cache. If the value returned is `false`, it means the value is not available with the key to retrieve it from cache. If the value returned is `false`, it means the value is not available
in cache and we should regenerate it: in cache and we should regenerate it:
...@@ -134,18 +134,20 @@ may be cached in the application. It is **NOT** required that the key is unique ...@@ -134,18 +134,20 @@ may be cached in the application. It is **NOT** required that the key is unique
the cache component is intelligent enough to differentiate keys for different applications. the cache component is intelligent enough to differentiate keys for different applications.
Some cache storages, such as MemCache, APC, support retrieving multiple cached values in a batch mode, Some cache storages, such as MemCache, APC, support retrieving multiple cached values in a batch mode,
which may reduce the overhead involved in retrieving cached data. A method named [[mget()]] is provided which may reduce the overhead involved in retrieving cached data. A method named [[yii\caching\Cache::mget()|mget()]] is provided
to exploit this feature. In case the underlying cache storage does not support this feature, to exploit this feature. In case the underlying cache storage does not support this feature,
[[mget()]] will still simulate it. [[yii\caching\Cache::mget()|mget()]] will still simulate it.
To remove a cached value from cache, call [[delete()]]; and to remove everything from cache, call [[flush()]]. To remove a cached value from cache, call [[yii\caching\Cache::delete()|delete()]]; and to remove everything from cache, call
Be very careful when calling [[flush()]] because it also removes cached data that are from other applications. [[yii\caching\Cache::flush()|flush()]].
Be very careful when calling [[yii\caching\Cache::flush()|flush()]] because it also removes cached data that are from
other applications if the cache is shared among different applications.
Note, because [[Cache]] implements `ArrayAccess`, a cache component can be used liked an array. The followings Note, because [[yii\caching\Cache]] implements `ArrayAccess`, a cache component can be used liked an array. The followings
are some examples: are some examples:
```php ```php
$cache = Yii::$app->getComponent('cache'); $cache = Yii::$app->cache;
$cache['var1'] = $value1; // equivalent to: $cache->set('var1', $value1); $cache['var1'] = $value1; // equivalent to: $cache->set('var1', $value1);
$value2 = $cache['var2']; // equivalent to: $value2 = $cache->get('var2'); $value2 = $cache['var2']; // equivalent to: $value2 = $cache->get('var2');
``` ```
...@@ -157,10 +159,10 @@ are caching the content of some file and the file is changed, we should invalida ...@@ -157,10 +159,10 @@ are caching the content of some file and the file is changed, we should invalida
content from the file instead of the cache. content from the file instead of the cache.
We represent a dependency as an instance of [[\yii\caching\Dependency]] or its child class. We pass the dependency We represent a dependency as an instance of [[\yii\caching\Dependency]] or its child class. We pass the dependency
instance along with the data to be cached when calling `set()`. instance along with the data to be cached when calling [[yii\caching\Cache::set()|set()]].
```php ```php
use yii\cache\FileDependency; use yii\caching\FileDependency;
// the value will expire in 30 seconds // the value will expire in 30 seconds
// it may also be invalidated earlier if the dependent file is changed // it may also be invalidated earlier if the dependent file is changed
...@@ -172,12 +174,12 @@ get a false value, indicating the data needs to be regenerated. ...@@ -172,12 +174,12 @@ get a false value, indicating the data needs to be regenerated.
Below is a summary of the available cache dependencies: Below is a summary of the available cache dependencies:
- [[\yii\cache\FileDependency]]: the dependency is changed if the file's last modification time is changed. - [[\yii\caching\FileDependency]]: the dependency is changed if the file's last modification time is changed.
- [[\yii\cache\GroupDependency]]: marks a cached data item with a group name. You may invalidate the cached data items - [[\yii\caching\GroupDependency]]: marks a cached data item with a group name. You may invalidate the cached data items
with the same group name all at once by calling [[\yii\cache\GroupDependency::invalidate()]]. with the same group name all at once by calling [[\yii\caching\GroupDependency::invalidate()]].
- [[\yii\cache\DbDependency]]: the dependency is changed if the query result of the specified SQL statement is changed. - [[\yii\caching\DbDependency]]: the dependency is changed if the query result of the specified SQL statement is changed.
- [[\yii\cache\ChainedDependency]]: the dependency is changed if any of the dependencies on the chain is changed. - [[\yii\caching\ChainedDependency]]: the dependency is changed if any of the dependencies on the chain is changed.
- [[\yii\cache\ExpressionDependency]]: the dependency is changed if the result of the specified PHP expression is - [[\yii\caching\ExpressionDependency]]: the dependency is changed if the result of the specified PHP expression is
changed. changed.
### Query Caching ### Query Caching
......
...@@ -103,7 +103,7 @@ by Yii with the corresponding types depended on your database management system. ...@@ -103,7 +103,7 @@ by Yii with the corresponding types depended on your database management system.
You can use them to write database independent migrations. You can use them to write database independent migrations.
For example `pk` will be replaced by `int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY` For example `pk` will be replaced by `int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY`
for MySQL and `integer PRIMARY KEY AUTOINCREMENT NOT NULL` for sqlite. for MySQL and `integer PRIMARY KEY AUTOINCREMENT NOT NULL` for sqlite.
See documentation of [[QueryBuilder::getColumnType()]] for more details and a list See documentation of [[yii\db\QueryBuilder::getColumnType()]] for more details and a list
of available types. You may also use the constants defined in [[\yii\db\Schema]] to of available types. You may also use the constants defined in [[\yii\db\Schema]] to
define column types. define column types.
......
...@@ -13,8 +13,9 @@ You can execute controller action using the following syntax: ...@@ -13,8 +13,9 @@ You can execute controller action using the following syntax:
yii <route> [--option1=value1 --option2=value2 ... argument1 argument2 ...] yii <route> [--option1=value1 --option2=value2 ... argument1 argument2 ...]
``` ```
For example, `MigrationController::actionCreate()` with `MigrationController::$migrationTable` set can be called from command For example, [[yii\console\controllers\MigrateController::actionCreate()|MigrateController::actionCreate()]]
line like the following: with [[yii\console\controllers\MigrateController::$migrationTable|MigrateController::$migrationTable]] set can
be called from command line like the following:
``` ```
yii migrate/create --migrationTable=my_migration yii migrate/create --migrationTable=my_migration
...@@ -79,7 +80,8 @@ you define one or several actions that correspond to the sub-commands of the com ...@@ -79,7 +80,8 @@ you define one or several actions that correspond to the sub-commands of the com
to implement certain tasks for that particular sub-command. to implement certain tasks for that particular sub-command.
When running a command, you need to specify the route to the corresponding controller action. For example, When running a command, you need to specify the route to the corresponding controller action. For example,
the route `migrate/create` specifies the sub-command corresponding to the `MigrateController::actionCreate()` action method. the route `migrate/create` specifies the sub-command corresponding to the
[[yii\console\controllers\MigrateController::actionCreate()|MigrateController::actionCreate()]] action method.
If a route does not contain an action ID, the default action will be executed. If a route does not contain an action ID, the default action will be executed.
### Options ### Options
......
...@@ -221,7 +221,7 @@ Action Filters ...@@ -221,7 +221,7 @@ Action Filters
Action filters are implemented via behaviors. You should extend from `ActionFilter` to Action filters are implemented via behaviors. You should extend from `ActionFilter` to
define a new filter. To use a filter, you should attach the filter class to the controller define a new filter. To use a filter, you should attach the filter class to the controller
as a behavior. For example, to use the [[AccessControl]] filter, you should have the following as a behavior. For example, to use the [[yii\web\AccessControl]] filter, you should have the following
code in a controller: code in a controller:
```php ```php
...@@ -238,8 +238,8 @@ public function behaviors() ...@@ -238,8 +238,8 @@ public function behaviors()
} }
``` ```
In order to learn more about access control check [authorization](authorization.md) section of the guide. In order to learn more about access control check the [authorization](authorization.md) section of the guide.
Two other filters, [[PageCache]] and [[HttpCache]] are described in [caching](caching.md) section of the guide. Two other filters, [[yii\web\PageCache]] and [[yii\web\HttpCache]] are described in the [caching](caching.md) section of the guide.
Catching all incoming requests Catching all incoming requests
------------------------------ ------------------------------
......
...@@ -78,14 +78,16 @@ use yii\widgets\ActiveForm; ...@@ -78,14 +78,16 @@ use yii\widgets\ActiveForm;
<?php ActiveForm::end() ?> <?php ActiveForm::end() ?>
``` ```
In the above code, `ActiveForm::begin()` not only creates a form instance, but also marks the beginning of the form. In the above code, [[yii\widgets\ActiveForm::begin()|ActiveForm::begin()]] not only creates a form instance, but also marks the beginning of the form.
All of the content placed between `ActiveForm::begin()` and `ActiveForm::end()` will be wrapped within the `<form>` tag. All of the content placed between [[yii\widgets\ActiveForm::begin()|ActiveForm::begin()]] and
[[yii\widgets\ActiveForm::end()|ActiveForm::end()]] will be wrapped within the `<form>` tag.
As with any widget, you can specify some options as to how the widget should be configured by passing an array to As with any widget, you can specify some options as to how the widget should be configured by passing an array to
the `begin` method. In this case, an extra CSS class and identifying ID are passed to be used in the opening `<form>` tag. the `begin` method. In this case, an extra CSS class and identifying ID are passed to be used in the opening `<form>` tag.
In order to create a form element in the form, along with the element's label, and any application JavaScript validation, In order to create a form element in the form, along with the element's label, and any application JavaScript validation,
the `field` method of the Active Form widget is called. When the invocation of this method is echoed directly, the result the [[yii\widgets\ActiveForm::field()|ActiveForm::field()]] method of the Active Form widget is called.
is a regular (text) input. To customize the output, you can chain additional methods to this call: When the invocation of this method is echoed directly, the result is a regular (text) input.
To customize the output, you can chain additional methods to this call:
```php ```php
<?= $form->field($model, 'password')->passwordInput() ?> <?= $form->field($model, 'password')->passwordInput() ?>
......
The Definitive Guide to Yii 2.0
===============================
This tutorial is released under the [Terms of Yii Documentation](http://www.yiiframework.com/doc/terms/).
All Rights Reserved.
2014 (c) Yii Software LLC.
Introduction Introduction
============ ------------
- [Overview](overview.md) - What is Yii and what is it good for? - [Overview](overview.md) - What is Yii and what is it good for?
Getting started Getting started
=============== ---------------
- [Upgrading from 1.1 to 2.0](upgrade-from-v1.md) - [Upgrading from 1.1 to 2.0](upgrade-from-v1.md)
- [Installation](installation.md) - How to download Yii and configure the Webserver? - [Installation](installation.md) - How to download Yii and configure the Webserver?
...@@ -16,7 +26,7 @@ Getting started ...@@ -16,7 +26,7 @@ Getting started
- [Creating your own Application structure](apps-own.md) - Learn how to start from scratch. - [Creating your own Application structure](apps-own.md) - Learn how to start from scratch.
Base concepts Base concepts
============= -------------
- [Basic concepts of Yii](basics.md) - The Object and Component class, Path aliases and autoloading - [Basic concepts of Yii](basics.md) - The Object and Component class, Path aliases and autoloading
- [MVC](mvc.md) - Implementation of MVC in Yii and a typical MVC application flow - [MVC](mvc.md) - Implementation of MVC in Yii and a typical MVC application flow
...@@ -27,7 +37,7 @@ Base concepts ...@@ -27,7 +37,7 @@ Base concepts
- [Behaviors](behaviors.md) - [Behaviors](behaviors.md)
Database Database
======== --------
- [Basics](database-basics.md) - Connecting to a database, basic queries, transactions and schema manipulation - [Basics](database-basics.md) - Connecting to a database, basic queries, transactions and schema manipulation
- [Query Builder](query-builder.md) - Querying the database using a simple abstraction layer - [Query Builder](query-builder.md) - Querying the database using a simple abstraction layer
...@@ -35,7 +45,7 @@ Database ...@@ -35,7 +45,7 @@ Database
- [Database Migration](console-migrate.md) - Versioning your database with database migrations - [Database Migration](console-migrate.md) - Versioning your database with database migrations
Developers Toolbox Developers Toolbox
================== ------------------
- [Automatic Code Generation](gii.md) - [Automatic Code Generation](gii.md)
- [Debug toolbar and debugger](module-debug.md) - [Debug toolbar and debugger](module-debug.md)
...@@ -43,7 +53,7 @@ Developers Toolbox ...@@ -43,7 +53,7 @@ Developers Toolbox
- [Logging](logging.md) - [Logging](logging.md)
Extensions and 3rd party libraries Extensions and 3rd party libraries
================================== ----------------------------------
- [Composer](composer.md) - How to manage applications dependencies via composer - [Composer](composer.md) - How to manage applications dependencies via composer
- [Extending Yii](extensions.md) - [Extending Yii](extensions.md)
...@@ -51,7 +61,7 @@ Extensions and 3rd party libraries ...@@ -51,7 +61,7 @@ Extensions and 3rd party libraries
- [Using Yii together with 3rd-Party Systems](using-3rd-party-libraries.md) - Using Yii in 3rd-Party Systems and using Yii 1 and 2 together - [Using Yii together with 3rd-Party Systems](using-3rd-party-libraries.md) - Using Yii in 3rd-Party Systems and using Yii 1 and 2 together
Security and access control Security and access control
=========================== ---------------------------
- [Authentication](authentication.md) - Identifying Users - [Authentication](authentication.md) - Identifying Users
- [Authorization](authorization.md) - Access control and RBAC - [Authorization](authorization.md) - Access control and RBAC
...@@ -59,7 +69,7 @@ Security and access control ...@@ -59,7 +69,7 @@ Security and access control
- [Views security](view.md#security) - how to prevent XSS - [Views security](view.md#security) - how to prevent XSS
Data providers, lists and grids Data providers, lists and grids
=============================== -------------------------------
- Overview - Overview
- Data providers - Data providers
...@@ -67,7 +77,7 @@ Data providers, lists and grids ...@@ -67,7 +77,7 @@ Data providers, lists and grids
- Lists - Lists
Advanced Topics Advanced Topics
=============== ---------------
- [Asset Management](assets.md) - [Asset Management](assets.md)
- [Working with forms](form.md) - [Working with forms](form.md)
...@@ -81,7 +91,7 @@ Advanced Topics ...@@ -81,7 +91,7 @@ Advanced Topics
- [Testing](testing.md) - [Testing](testing.md)
References References
========== ----------
- [Model validation reference](validation.md) - [Model validation reference](validation.md)
- [Official Composer documentation](http://getcomposer.org) - [Official Composer documentation](http://getcomposer.org)
...@@ -23,16 +23,16 @@ default. ...@@ -23,16 +23,16 @@ default.
There are multiple severity levels and corresponding methods available: There are multiple severity levels and corresponding methods available:
- `\Yii::trace` used maily for development purpose to indicate workflow of some code. Note that it only works in - [[Yii::trace]] used maily for development purpose to indicate workflow of some code. Note that it only works in
development mode when `YII_DEBUG` is set to `true`. development mode when `YII_DEBUG` is set to `true`.
- `\Yii::error` used when there's unrecoverable error. - [[Yii::error]] used when there's unrecoverable error.
- `\Yii::warning` used when an error occured but execution can be continued. - [[Yii::warning]] used when an error occured but execution can be continued.
- `\Yii::info` used to keep record of important events such as administrator logins. - [[Yii::info]] used to keep record of important events such as administrator logins.
Log targets Log targets
----------- -----------
When one of the logging methods is called, message is passed to `\yii\log\Logger` component also accessible as When one of the logging methods is called, message is passed to [[yii\log\Logger]] component also accessible as
`Yii::$app->log`. Logger accumulates messages in memory and then when there are enough messages or when current `Yii::$app->log`. Logger accumulates messages in memory and then when there are enough messages or when current
request finishes, sends them to different log targets, such as file or email. request finishes, sends them to different log targets, such as file or email.
...@@ -72,13 +72,15 @@ Each log target can have a name and can be referenced via the [[targets]] proper ...@@ -72,13 +72,15 @@ Each log target can have a name and can be referenced via the [[targets]] proper
Yii::$app->log->targets['file']->enabled = false; Yii::$app->log->targets['file']->enabled = false;
``` ```
When the application ends or [[flushInterval]] is reached, Logger will call [[flush()]] to send logged messages to When the application ends or [[yii\log\Logger::flushInterval|flushInterval]] is reached, Logger will call
different log targets, such as file, email, Web. [[yii\log\Logger::flush()|flush()]] to send logged messages to different log targets, such as file, email, web.
Configuring context information Configuring context information
------------------------------- -------------------------------
TDB
Profiling Profiling
--------- ---------
......
...@@ -28,7 +28,7 @@ The following diagram shows a typical workflow of a Yii application handling a ...@@ -28,7 +28,7 @@ The following diagram shows a typical workflow of a Yii application handling a
1. A user makes a request of the URL `http://www.example.com/index.php?r=post/show&id=1`. 1. A user makes a request of the URL `http://www.example.com/index.php?r=post/show&id=1`.
The Web server handles the request by executing the bootstrap script `index.php`. The Web server handles the request by executing the bootstrap script `index.php`.
2. The bootstrap script creates an [[Application|yii\web\Application]] instance and runs it. 2. The bootstrap script creates an [[yii\web\Application|Application]] instance and runs it.
3. The Application instance obtains the detailed user request information from an application component named `request`. 3. The Application instance obtains the detailed user request information from an application component named `request`.
4. The application determines which [controller](controller.md) and which action of that controller was requested. 4. The application determines which [controller](controller.md) and which action of that controller was requested.
This is accomplished with the help of an application component named `urlManager`. This is accomplished with the help of an application component named `urlManager`.
......
...@@ -158,7 +158,7 @@ Operator can be one of the following: ...@@ -158,7 +158,7 @@ Operator can be one of the following:
in the generated condition. in the generated condition.
- `or not like`: similar to the `not like` operator except that `OR` is used to concatenate - `or not like`: similar to the `not like` operator except that `OR` is used to concatenate
the `NOT LIKE` predicates. the `NOT LIKE` predicates.
- `exists`: requires one operand which must be an instance of [[Query]] representing the sub-query. - `exists`: requires one operand which must be an instance of [[yii\db\Query]] representing the sub-query.
It will build a `EXISTS (sub-query)` expression. It will build a `EXISTS (sub-query)` expression.
- `not exists`: similar to the `exists` operator and builds a `NOT EXISTS (sub-query)` expression. - `not exists`: similar to the `exists` operator and builds a `NOT EXISTS (sub-query)` expression.
......
...@@ -106,7 +106,7 @@ to achieve the same goal. ...@@ -106,7 +106,7 @@ to achieve the same goal.
In the following we will describe how to write a `UserProfile` unit test class using `yii2-codeception`. In the following we will describe how to write a `UserProfile` unit test class using `yii2-codeception`.
In your unit test class extending [[yii\codeception\DbTestCase]] or [[yii\codeception\TestCase]], In your unit test class extending [[yii\codeception\DbTestCase]] or [[yii\codeception\TestCase]],
declare which fixtures you want to use in the [[yii\testFixtureTrait::fixtures()|fixtures()]] method. For example, declare which fixtures you want to use in the [[yii\test\FixtureTrait::fixtures()|fixtures()]] method. For example,
```php ```php
namespace app\tests\unit\models; namespace app\tests\unit\models;
......
...@@ -169,7 +169,7 @@ In order to use parameterized hostnames, simply declare URL rules with host info ...@@ -169,7 +169,7 @@ In order to use parameterized hostnames, simply declare URL rules with host info
In the above example the first segment of the hostname is treated as the user parameter while the first segment In the above example the first segment of the hostname is treated as the user parameter while the first segment
of the path info is treated as the lang parameter. The rule corresponds to the `user/profile` route. of the path info is treated as the lang parameter. The rule corresponds to the `user/profile` route.
Note that [[UrlManager::showScriptName]] will not take effect when a URL is being created using a rule with a parameterized hostname. Note that [[yii\web\UrlManager::showScriptName]] will not take effect when a URL is being created using a rule with a parameterized hostname.
Also note that any rule with a parameterized hostname should NOT contain the subfolder if the application is under Also note that any rule with a parameterized hostname should NOT contain the subfolder if the application is under
a subfolder of the Web root. For example, if the application is under `http://www.example.com/sandbox/blog`, then we a subfolder of the Web root. For example, if the application is under `http://www.example.com/sandbox/blog`, then we
...@@ -189,9 +189,13 @@ return [ ...@@ -189,9 +189,13 @@ return [
]; ];
``` ```
### Handling REST ### Handling REST requests
TBD: [[\yii\web\VerbFiler]] TBD:
- RESTful routing: [[\yii\web\VerbFilter]], [[\yii\web\UrlManager::$rules]]
- Json API:
- response: [[\yii\web\Response::format]]
- request: [[yii\web\Request::$parsers]], [[\yii\web\JsonParser]]
URL parsing URL parsing
......
...@@ -42,10 +42,10 @@ When using composer you add the following to your composer.json in order to add ...@@ -42,10 +42,10 @@ When using composer you add the following to your composer.json in order to add
"require": { "require": {
"yiisoft/yii": "*", "yiisoft/yii": "*",
"yiisoft/yii2": "*", "yiisoft/yii2": "*",
}, },
``` ```
Start from defining your own descendant of [[\yii\BaseYii]]: Start from defining your own descendant of [[yii\BaseYii]]:
```php ```php
$yii2path = '/path/to/yii2'; $yii2path = '/path/to/yii2';
...@@ -59,7 +59,7 @@ Yii::$classMap = include($yii2path . '/classes.php'); ...@@ -59,7 +59,7 @@ Yii::$classMap = include($yii2path . '/classes.php');
``` ```
Now we have a class, which suites Yii2, but causes fatal errors for Yii1. Now we have a class, which suites Yii2, but causes fatal errors for Yii1.
So, first of all, we need to include [[\YiiBase]] of Yii1 source code to our 'Yii' class So, first of all, we need to include `YiiBase` of Yii1 source code to our 'Yii' class
definition file: definition file:
```php ```php
...@@ -76,7 +76,7 @@ Yii::$classMap = include($yii2path . '/classes.php'); ...@@ -76,7 +76,7 @@ Yii::$classMap = include($yii2path . '/classes.php');
``` ```
Using this, defines all necessary constants and autoloader of Yii1. Using this, defines all necessary constants and autoloader of Yii1.
Now we need to add all fields and methods from [[\YiiBase]] of Yii1 to our 'Yii' class. Now we need to add all fields and methods from `YiiBase` of Yii1 to our 'Yii' class.
Unfortunally, there is no way to do so but copy-paste: Unfortunally, there is no way to do so but copy-paste:
```php ```php
......
...@@ -10,7 +10,7 @@ Standard Yii validators ...@@ -10,7 +10,7 @@ Standard Yii validators
Standard Yii validators could be specified using aliases instead of referring to class names. Here's the list of all Standard Yii validators could be specified using aliases instead of referring to class names. Here's the list of all
validators bundled with Yii with their most useful properties: validators bundled with Yii with their most useful properties:
### `boolean`: [[BooleanValidator]] ### `boolean`: [[yii\validation\BooleanValidator|BooleanValidator]]
Checks if the attribute value is a boolean value. Checks if the attribute value is a boolean value.
...@@ -18,15 +18,15 @@ Checks if the attribute value is a boolean value. ...@@ -18,15 +18,15 @@ Checks if the attribute value is a boolean value.
- `falseValue`, the value representing false status. _(0)_ - `falseValue`, the value representing false status. _(0)_
- `strict`, whether to compare the type of the value and `trueValue`/`falseValue`. _(false)_ - `strict`, whether to compare the type of the value and `trueValue`/`falseValue`. _(false)_
### `captcha`: [[CaptchaValidator]] ### `captcha`: [[yii\captcha\CaptchaValidator|CaptchaValidator]]
Validates that the attribute value is the same as the verification code displayed in the CAPTCHA. Should be used together Validates that the attribute value is the same as the verification code displayed in the CAPTCHA. Should be used together
with [[CaptchaAction]]. with [[yii\captcha\CaptchaAction]].
- `caseSensitive` whether the comparison is case sensitive. _(false)_ - `caseSensitive` whether the comparison is case sensitive. _(false)_
- `captchaAction` the route of the controller action that renders the CAPTCHA image. _('site/captcha')_ - `captchaAction` the route of the controller action that renders the CAPTCHA image. _('site/captcha')_
### `compare`: [[CompareValidator]] ### `compare`: [[yii\validation\CompareValidator|CompareValidator]]
Compares the specified attribute value with another value and validates if they are equal. Compares the specified attribute value with another value and validates if they are equal.
...@@ -34,27 +34,28 @@ Compares the specified attribute value with another value and validates if they ...@@ -34,27 +34,28 @@ Compares the specified attribute value with another value and validates if they
- `compareValue` the constant value to be compared with. - `compareValue` the constant value to be compared with.
- `operator` the operator for comparison. _('==')_ - `operator` the operator for comparison. _('==')_
### `date`: [[DateValidator]] ### `date`: [[yii\validation\DateValidator|DateValidator]]
Verifies if the attribute represents a date, time or datetime in a proper format. Verifies if the attribute represents a date, time or datetime in a proper format.
- `format` the date format that the value being validated should follow according to [[http://www.php.net/manual/en/datetime.createfromformat.php]]. _('Y-m-d')_ - `format` the date format that the value being validated should follow according to
[PHP date_create_from_format](http://www.php.net/manual/en/datetime.createfromformat.php). _('Y-m-d')_
- `timestampAttribute` the name of the attribute to receive the parsing result. - `timestampAttribute` the name of the attribute to receive the parsing result.
### `default`: [[DefaultValueValidator]] ### `default`: [[yii\validation\DefaultValueValidator|DefaultValueValidator]]
Sets the attribute to be the specified default value. Sets the attribute to be the specified default value.
- `value` the default value to be set to the specified attributes. - `value` the default value to be set to the specified attributes.
### `double`: [[NumberValidator]] ### `double`: [[yii\validation\NumberValidator|NumberValidator]]
Validates that the attribute value is a number. Validates that the attribute value is a number.
- `max` limit of the number. _(null)_ - `max` limit of the number. _(null)_
- `min` lower limit of the number. _(null)_ - `min` lower limit of the number. _(null)_
### `email`: [[EmailValidator]] ### `email`: [[yii\validation\EmailValidator|EmailValidator]]
Validates that the attribute value is a valid email address. Validates that the attribute value is a valid email address.
...@@ -63,7 +64,7 @@ Validates that the attribute value is a valid email address. ...@@ -63,7 +64,7 @@ Validates that the attribute value is a valid email address.
- `checkPort` whether to check port 25 for the email address. _(false)_ - `checkPort` whether to check port 25 for the email address. _(false)_
- `enableIDN` whether validation process should take into account IDN (internationalized domain names). _(false)_ - `enableIDN` whether validation process should take into account IDN (internationalized domain names). _(false)_
### `exist`: [[ExistValidator]] ### `exist`: [[yii\validation\ExistValidator|ExistValidator]]
Validates that the attribute value exists in a table. Validates that the attribute value exists in a table.
...@@ -72,7 +73,7 @@ Validates that the attribute value exists in a table. ...@@ -72,7 +73,7 @@ Validates that the attribute value exists in a table.
- `targetAttribute` the ActiveRecord attribute name that should be used to look for the attribute value being validated. - `targetAttribute` the ActiveRecord attribute name that should be used to look for the attribute value being validated.
_(name of the attribute being validated)_ _(name of the attribute being validated)_
### `file`: [[FileValidator]] ### `file`: [[yii\validation\FileValidator|FileValidator]]
Verifies if an attribute is receiving a valid uploaded file. Verifies if an attribute is receiving a valid uploaded file.
...@@ -81,7 +82,7 @@ Verifies if an attribute is receiving a valid uploaded file. ...@@ -81,7 +82,7 @@ Verifies if an attribute is receiving a valid uploaded file.
- `maxSize` the maximum number of bytes required for the uploaded file. - `maxSize` the maximum number of bytes required for the uploaded file.
- `maxFiles` the maximum file count the given attribute can hold. _(1)_ - `maxFiles` the maximum file count the given attribute can hold. _(1)_
### `filter`: [[FilterValidator]] ### `filter`: [[yii\validation\FilterValidator|FilterValidator]]
Converts the attribute value according to a filter. Converts the attribute value according to a filter.
...@@ -102,7 +103,7 @@ Or an anonymous function: ...@@ -102,7 +103,7 @@ Or an anonymous function:
}], }],
``` ```
### `in`: [[RangeValidator]] ### `in`: [[yii\validation\RangeValidator|RangeValidator]]
Validates that the attribute value is among a list of values. Validates that the attribute value is among a list of values.
...@@ -110,7 +111,7 @@ Validates that the attribute value is among a list of values. ...@@ -110,7 +111,7 @@ Validates that the attribute value is among a list of values.
- `strict` whether the comparison is strict (both type and value must be the same). _(false)_ - `strict` whether the comparison is strict (both type and value must be the same). _(false)_
- `not` whether to invert the validation logic. _(false)_ - `not` whether to invert the validation logic. _(false)_
### `inline`: [[InlineValidator]] ### `inline`: [[yii\validation\InlineValidator|InlineValidator]]
Uses a custom function to validate the attribute. You need to define a public method in your Uses a custom function to validate the attribute. You need to define a public method in your
model class which will evaluate the validity of the attribute. For example, if an attribute model class which will evaluate the validity of the attribute. For example, if an attribute
...@@ -125,39 +126,40 @@ public function myValidationMethod($attribute) { ...@@ -125,39 +126,40 @@ public function myValidationMethod($attribute) {
} }
``` ```
### `integer`: [[NumberValidator]] ### `integer`: [[yii\validation\NumberValidator|NumberValidator]]
Validates that the attribute value is an integer number. Validates that the attribute value is an integer number.
- `max` limit of the number. _(null)_ - `max` limit of the number. _(null)_
- `min` lower limit of the number. _(null)_ - `min` lower limit of the number. _(null)_
### `match`: [[RegularExpressionValidator]] ### `match`: [[yii\validation\RegularExpressionValidator|RegularExpressionValidator]]
Validates that the attribute value matches the specified pattern defined by regular expression. Validates that the attribute value matches the specified pattern defined by regular expression.
- `pattern` the regular expression to be matched with. - `pattern` the regular expression to be matched with.
- `not` whether to invert the validation logic. _(false)_ - `not` whether to invert the validation logic. _(false)_
### `number`: [[NumberValidator]] ### `number`: [[yii\validation\NumberValidator|NumberValidator]]
Validates that the attribute value is a number. Validates that the attribute value is a number.
- `max` limit of the number. _(null)_ - `max` limit of the number. _(null)_
- `min` lower limit of the number. _(null)_ - `min` lower limit of the number. _(null)_
### `required`: [[RequiredValidator]] ### `required`: [[yii\validation\RequiredValidator|RequiredValidator]]
Validates that the specified attribute does not have null or empty value. Validates that the specified attribute does not have null or empty value.
- `requiredValue` the desired value that the attribute must have. _(any)_ - `requiredValue` the desired value that the attribute must have. _(any)_
- `strict` whether the comparison between the attribute value and [[requiredValue]] is strict. _(false)_ - `strict` whether the comparison between the attribute value and
[[yii\validation\RequiredValidator::requiredValue|requiredValue]] is strict. _(false)_
### `safe`: [[SafeValidator]] ### `safe`: [[yii\validation\SafeValidator|SafeValidator]]
Serves as a dummy validator whose main purpose is to mark the attributes to be safe for massive assignment. Serves as a dummy validator whose main purpose is to mark the attributes to be safe for massive assignment.
### `string`: [[StringValidator]] ### `string`: [[yii\validation\StringValidator|StringValidator]]
Validates that the attribute value is of certain length. Validates that the attribute value is of certain length.
...@@ -166,7 +168,7 @@ Validates that the attribute value is of certain length. ...@@ -166,7 +168,7 @@ Validates that the attribute value is of certain length.
- `min` minimum length. If not set, it means no minimum length limit. - `min` minimum length. If not set, it means no minimum length limit.
- `encoding` the encoding of the string value to be validated. _([[\yii\base\Application::charset]])_ - `encoding` the encoding of the string value to be validated. _([[\yii\base\Application::charset]])_
### `unique`: [[UniqueValidator]] ### `unique`: [[yii\validation\UniqueValidator|UniqueValidator]]
Validates that the attribute value is unique in the corresponding database table. Validates that the attribute value is unique in the corresponding database table.
...@@ -175,7 +177,7 @@ Validates that the attribute value is unique in the corresponding database table ...@@ -175,7 +177,7 @@ Validates that the attribute value is unique in the corresponding database table
- `targetAttribute` the ActiveRecord attribute name that should be used to look for the attribute value being validated. - `targetAttribute` the ActiveRecord attribute name that should be used to look for the attribute value being validated.
_(name of the attribute being validated)_ _(name of the attribute being validated)_
### `url`: [[UrlValidator]] ### `url`: [[yii\validation\UrlValidator|UrlValidator]]
Validates that the attribute value is a valid http or https URL. Validates that the attribute value is a valid http or https URL.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment