本文整理汇总了PHP中yii\widgets\ActiveForm::className方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveForm::className方法的具体用法?PHP ActiveForm::className怎么用?PHP ActiveForm::className使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\widgets\ActiveForm
的用法示例。
在下文中一共展示了ActiveForm::className方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* @inheritdoc
* @throws InvalidConfigException
*/
public function init()
{
foreach (['form', 'model', 'fields'] as $attribute) {
if ($this->{$attribute} === null) {
throw new InvalidConfigException(self::className() . '::' . $attribute . ' should be set');
}
}
if (!$this->form instanceof ActiveForm) {
throw new InvalidConfigException(self::className() . '::form' . ' should be instance of ' . ActiveForm::className());
}
parent::init();
}
示例2: run
/**
* @inheritdoc
*/
public function run($id)
{
/* @var $model Model|ActiveRecordInterface|\yii2tech\ar\variation\VariationBehavior */
$model = $this->findModel($id);
$model->scenario = $this->scenario;
$post = Yii::$app->request->post();
if ($model->load($post) && Model::loadMultiple($model->getVariationModels(), $post)) {
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = Response::FORMAT_JSON;
return call_user_func_array([ActiveForm::className(), 'validate'], array_merge([$model, $model->getVariationModels()]));
}
if ($model->save()) {
$url = array_merge(['view'], Yii::$app->request->getQueryParams(), ['id' => implode(',', array_values($model->getPrimaryKey(true)))]);
return $this->controller->redirect($url);
}
}
return $this->controller->render($this->view, ['model' => $model]);
}
示例3: afterAjaxValidate
/**
* Performs AJAX validation of the role models via [[ActiveForm::validate()]].
* @param ActionEvent $event event instance.
*/
public function afterAjaxValidate($event)
{
$model = $event->model;
$roleModels = $this->getRoleModels($model);
$event->result = array_merge($event->result, call_user_func_array([ActiveForm::className(), 'validate'], $roleModels));
}