Пример #1
0
 /**
  * Updates an existing Role model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if (\Yii::$app->request->isAjax) {
         \Yii::$app->response->format = Response::FORMAT_JSON;
         $model->load(\Yii::$app->request->post());
         return ActiveForm::validate($model);
     }
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         \Yii::$app->session->setFlash(\yz\Yz::FLASH_SUCCESS, \Yii::t('admin/t', 'Record was successfully updated'));
         return $this->getCreateUpdateResponse($model);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
Пример #2
0
    <?php 
$box->beginBody();
?>
        <?php 
echo $form->field($model, 'description')->textInput();
?>
        <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 64]);
?>
        <?php 
echo $form->field($model, 'childRoles')->dropDownList($model->getChildRolesValues(), ['multiple' => 'multiple', 'size' => 10]);
?>
        <?php 
echo $form->field($model, 'childPermissions')->dropDownList($model->getChildPermissionsValues(), ['multiple' => 'multiple', 'size' => 20]);
?>

    <?php 
$box->endBody();
?>

    <?php 
$box->actions([AdminHtml::actionButton(AdminHtml::ACTION_SAVE_AND_STAY, $model->isNewRecord), AdminHtml::actionButton(AdminHtml::ACTION_SAVE_AND_LEAVE, $model->isNewRecord), AdminHtml::actionButton(AdminHtml::ACTION_SAVE_AND_CREATE, $model->isNewRecord)]);
?>

    <?php 
ActiveForm::end();
?>

<?php 
FormBox::end();