PHP Class yii2tech\admin\behaviors\ModelControlBehavior

This behavior should be attached to Controller instance.
Since: 1.0
Author: Paul Klimov ([email protected])
Inheritance: extends yii\base\Behavior
Exibir arquivo Open project: yii2tech/admin Class Usage Examples

Public Properties

Property Type Description
$modelClass the model class name. This property must be set. The model class must implement [[ActiveRecordInterface]].
$searchModelClass class name of the model which should be used as search model. This can be a PHP callback of following signature: php function (\yii\web\Controller $controller) { return new \yii\base\Model; } If not set it will be composed using [[modelClass]]. If yii2tech/ar-search extension is installed - [[\yii2tech\ar\search\ActiveSearchModel]] instance will be used as a search model.

Public Methods

Method Description
findModel ( string $id ) : yii\db\ActiveRecordInterface | Model Returns the data model based on the primary key given.
newModel ( ) : yii\db\ActiveRecordInterface | Model Creates new model instance.
newSearchModel ( ) : Model Creates new search model instance.

Method Details

findModel() public method

If the data model is not found, a 404 HTTP exception will be raised.
public findModel ( string $id ) : yii\db\ActiveRecordInterface | Model
$id string the ID of the model to be loaded. If the model has a composite primary key, the ID must be a string of the primary key values separated by commas. The order of the primary key values should follow that returned by the `primaryKey()` method of the model.
return yii\db\ActiveRecordInterface | yii\base\Model the model found

newModel() public method

Creates new model instance.
public newModel ( ) : yii\db\ActiveRecordInterface | Model
return yii\db\ActiveRecordInterface | yii\base\Model new model instance.

newSearchModel() public method

Creates new search model instance.
public newSearchModel ( ) : Model
return yii\base\Model new search model instance.

Property Details

$modelClass public_oe property

the model class name. This property must be set. The model class must implement [[ActiveRecordInterface]].
See also: newModel()
See also: findModel()
public $modelClass

$searchModelClass public_oe property

class name of the model which should be used as search model. This can be a PHP callback of following signature: php function (\yii\web\Controller $controller) { return new \yii\base\Model; } If not set it will be composed using [[modelClass]]. If yii2tech/ar-search extension is installed - [[\yii2tech\ar\search\ActiveSearchModel]] instance will be used as a search model.
See also: newSearchModel()
public $searchModelClass