Commit ce70a4e0 by Klimov Paul

Merge branch 'master' of github.com:yiisoft/yii2

parents e67ca1a6 292622f9
...@@ -18,7 +18,7 @@ The `Model` class is also the base class for more advanced models, such as [Acti ...@@ -18,7 +18,7 @@ The `Model` class is also the base class for more advanced models, such as [Acti
Please refer to the relevant documentation for more details about these advanced models. Please refer to the relevant documentation for more details about these advanced models.
> Info: You are not required to base your model classes on [[yii\base\Model]]. However, because there are many Yii > Info: You are not required to base your model classes on [[yii\base\Model]]. However, because there are many Yii
components built to support [[yii\base\Model]], it is usually the preferable base model classes. components built to support [[yii\base\Model]], it is usually the preferable base class for a model.
## Attributes <a name="attributes"></a> ## Attributes <a name="attributes"></a>
...@@ -27,6 +27,7 @@ Attributes are the properties that represent business data. By default, attribut ...@@ -27,6 +27,7 @@ Attributes are the properties that represent business data. By default, attribut
member variables if your model class extends directly from [[yii\base\Model]]. member variables if your model class extends directly from [[yii\base\Model]].
The following code creates a `ContactForm` model class with four attributes: `name`, `email`, `subject` and `body`. The following code creates a `ContactForm` model class with four attributes: `name`, `email`, `subject` and `body`.
This model represents the input data that is received from an HTML form.
```php ```php
namespace app\models; namespace app\models;
...@@ -67,6 +68,8 @@ foreach ($model as $name => $value) { ...@@ -67,6 +68,8 @@ foreach ($model as $name => $value) {
} }
``` ```
### Extending model attributes
The method [[yii\base\Model::attributes()]] defines and returns the names of the attributes in a model. The method [[yii\base\Model::attributes()]] defines and returns the names of the attributes in a model.
You may override this method to support different ways of defining attributes. For example, [[yii\db\ActiveRecord]] You may override this method to support different ways of defining attributes. For example, [[yii\db\ActiveRecord]]
does so by returning table column names as attribute names. Note that you may also need to override the magic does so by returning table column names as attribute names. Note that you may also need to override the magic
......
...@@ -780,7 +780,7 @@ class BaseConsole ...@@ -780,7 +780,7 @@ class BaseConsole
} }
static::output(" ? - Show help"); static::output(" ? - Show help");
goto top; goto top;
} elseif (!in_array($input, array_keys($options))) { } elseif (!array_key_exists($input, $options)) {
goto top; goto top;
} }
......
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