当前位置: 首页>>代码示例>>PHP>>正文


PHP UserForm::save方法代码示例

本文整理汇总了PHP中UserForm::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UserForm::save方法的具体用法?PHP UserForm::save怎么用?PHP UserForm::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserForm的用法示例。


在下文中一共展示了UserForm::save方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $model = new UserForm();
     if (($post = $this->request->getPost('UserForm', false)) !== false) {
         $model->attributes = $post;
         if ($model->save()) {
             $this->response(200, '更新用户成功');
         } else {
             $this->response(500, '更新用户失败');
         }
         $this->app->end();
     } else {
         if (($id = $this->request->getQuery('id', 0)) != false) {
             if (($user = User::model()->findByPk($id)) != false) {
                 $model->attributes = ['id' => $user->id, 'username' => $user->username, 'realname' => $user->realname, 'nickname' => $user->nickname, 'email' => $user->email, 'state' => $user->state];
                 $auth = $this->app->getAuthManager();
                 $roles = $auth->getRoleByUserId($id);
                 $role = [];
                 foreach ($roles as $item) {
                     $role[] = $item->getId();
                 }
                 $groups = $auth->getGroupByUserId($id);
                 $group = [];
                 foreach ($groups as $item) {
                     $group[] = $item->getId();
                 }
                 $this->render('edit', ['model' => $model, 'role' => $role, 'group' => $group, 'roleList' => Role::model()->findAll(), 'groupList' => Group::model()->findAll()]);
                 $this->app->end();
             }
         }
     }
     $this->response(404, '参数错误');
 }
开发者ID:syxoasis,项目名称:wakfu-sae,代码行数:33,代码来源:EditAction.php

示例2: actionAccount

 public function actionAccount()
 {
     $model = new UserForm();
     if (($post = $this->request->getPost('UserForm', false)) != false) {
         $model->attributes = $post;
         if ($model->save()) {
             $this->user->logout();
             $this->redirect($this->createUrl('index'));
         }
     }
     $this->render('account', ['model' => $model, 'service' => Service::model()->findByPk($this->user->getId())]);
 }
开发者ID:syxoasis,项目名称:wakfu-sae,代码行数:12,代码来源:IndexController.php

示例3: actionEdit

 public function actionEdit()
 {
     $model = new UserForm();
     if (($post = $this->request->getPost('UserForm', false)) !== false) {
         $post['state'] = -1;
         $model->attributes = $post;
         if ($model->save()) {
             $this->response(200, '更新用户成功');
         } else {
             $this->response(500, '更新用户失败');
         }
     } else {
         if (($id = $this->request->getQuery('id', 0)) != false) {
             if (($user = User::model()->findByPk($id)) != false) {
                 $model->attributes = ['id' => $user->id, 'username' => $user->username, 'realname' => $user->realname, 'nickname' => $user->nickname, 'email' => $user->email, 'state' => -1];
                 $this->render('edit', ['model' => $model]);
             }
         } else {
             $this->response(404, '参数错误');
         }
     }
 }
开发者ID:syxoasis,项目名称:wakfu-sae,代码行数:22,代码来源:AccountController.php

示例4: actionUpdate

 public function actionUpdate()
 {
     $companyId = Helper::getCompanyId(Yii::app()->request->getParam('companyId'));
     $id = Yii::app()->request->getParam('id');
     Until::isUpdateValid(array($id), $companyId, $this);
     //0,表示企业任何时候都在云端更新。
     if (Yii::app()->user->role > User::ADMIN && Yii::app()->user->userId != $id) {
         Yii::app()->user->setFlash('error', yii::t('app', '你没有权限修改'));
         $this->redirect(array('user/index', 'companyId' => $companyId));
     }
     $model = new UserForm();
     $model->find('lid=:id and dpid=:dpid and status=1', array(':id' => $id, ':dpid' => $companyId));
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = Yii::app()->request->getPost('UserForm');
         //$model->update_at=date('Y-m-d H:i:s',time());
         //var_dump($model->attributes);exit;
         if ($model->save()) {
             Yii::app()->user->setFlash('success', yii::t('app', '修改成功'));
             $this->redirect(array('user/index', 'companyId' => $companyId));
         }
     }
     $this->render('update', array('model' => $model));
 }
开发者ID:song-yuan,项目名称:wymenujp,代码行数:23,代码来源:UserController.php

示例5: configure

$methods = array('widgetChoiceTableMethod1', 'widgetChoiceTableMethod2', 'widgetChoiceTableMethod3');
foreach ($methods as $method) {
    $widget = new sfWidgetFormDoctrineChoice(array('model' => 'User', 'table_method' => $method));
    $t->is($widget->getChoices(), array(1 => 1));
}
$widget = new sfWidgetFormDoctrineChoice(array('model' => 'User', 'table_method' => 'widgetChoiceTableMethod4'));
$t->is($widget->getChoices(), array());
$user = new User();
$user->Groups[]->name = 'User Group 1';
$user->Groups[]->name = 'User Group 2';
class UserGroupForm extends GroupForm
{
    public function configure()
    {
        parent::configure();
        $this->useFields(array('name'));
    }
}
$userForm = new UserForm($user);
$userForm->embedRelation('Groups', 'UserGroupForm');
$data = array('username' => 'jonwage', 'password' => 'changeme', 'Groups' => array(0 => array('name' => 'New User Group 1 Name'), 1 => array('name' => 'New User Group 2 Name')));
$userForm->bind($data);
$t->is($userForm->isValid(), true);
if ($userForm->isValid()) {
    $userForm->save();
}
$t->is($user->Groups[0]->name, 'New User Group 1 Name');
$t->is($user->Groups[1]->name, 'New User Group 2 Name');
$form = new DefaultValueTestForm();
$validatorSchema = $form->getValidatorSchema();
$t->is($validatorSchema['name']->getOption('required'), false);
开发者ID:Phennim,项目名称:symfony1,代码行数:31,代码来源:FormTest.php

示例6: actionCreateAdmin

 /**
  * This action enables us to create an admin user for CiiMS
  */
 public function actionCreateAdmin()
 {
     $this->stage = Yii::app()->session['stage'] = 6;
     $model = new UserForm();
     if (Cii::get($_POST, 'UserForm') != NULL) {
         $model->attributes = Cii::get($_POST, 'UserForm', array());
         if ($model->save()) {
             $this->redirect($this->createUrl('/admin'));
         }
         $errors = $model->getErrors();
         $firstError = array_values($errors);
         Yii::app()->user->setFlash('error', Yii::t('Install.main', '{{warning}} {{error}}', array('{{warning}}' => CHtml::tag('strong', array(), Yii::t('Install.main', 'Warning!')), '{{error}}' => $firstError[0][0])));
     }
     $this->render('createadmin', array('model' => $model));
 }
开发者ID:fandikurnia,项目名称:CiiMS,代码行数:18,代码来源:DefaultController.php


注:本文中的UserForm::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。