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


PHP UserForm::bind方法代码示例

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


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

示例1: editAction

 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('users', ['action' => 'add']);
     }
     try {
         $user = $this->getUsersTable()->getUser($id);
     } catch (\Exception $ex) {
         return $this->redirect()->toRoute('users', ['action' => 'index']);
     }
     $form = new UserForm();
     $form->bind($user);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($user->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getUsersTable()->saveUser($user);
             return $this->redirect()->toRoute('users');
         }
     }
     return ['id' => $id, 'form' => $form];
 }
开发者ID:GlenHughes,项目名称:premiumclans,代码行数:25,代码来源:UsersController.php

示例2: bind

 public function bind(array $v = null, array $f = null)
 {
     $q = Doctrine_Query::create()->select('u.*')->from('User u')->where('(u.login = ? or u.email = ?) and u.password IS NULL and u.active=0', array($v['login'], $v['email']));
     if ($q->count() > 0) {
         foreach ($q->execute() as $rec) {
             $rec->delete();
         }
     }
     parent::bind($v, $f);
 }
开发者ID:rollmax,项目名称:read2read,代码行数:10,代码来源:RegisterUserUForm.class.php

示例3: bind

 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     // remove the embedded new form if the name field was not provided
     if (is_null($taintedValues['new_samba_account']['hostname']) || strlen($taintedValues['new_samba_account']['hostname']) === 0) {
         unset($this->embeddedForms['new_samba_account'], $taintedValues['new_samba_account']);
         $this->validatorSchema['new_samba_account'] = new sfValidatorPass();
     }
     // call parent bind method
     parent::bind($taintedValues, $taintedFiles);
 }
开发者ID:habtom,项目名称:uas,代码行数:10,代码来源:BackendUserForm.class.php

示例4: signupAction

 public function signupAction()
 {
     $account = new Account();
     $accountForm = new AccountForm($account);
     $this->view->accountForm = $accountForm;
     $user = new User();
     $userForm = new UserForm($user);
     $this->view->userForm = $userForm;
     $this->view->setVar("tab", 0);
     if ($this->request->isPost()) {
         try {
             $this->db->begin();
             $accountForm->bind($this->request->getPost(), $account);
             $userForm->bind($this->request->getPost(), $user);
             $idAccountplan = $accountForm->getValue('idAccountplan');
             $idAccounttype = $accountForm->getValue('idAccounttype');
             $city = $accountForm->getValue('city');
             $pass1 = $userForm->getValue('pass1');
             $pass2 = $userForm->getValue('pass2');
             $email = $this->request->getPost('email');
             $this->validateEqualsPassword($pass1, $pass2);
             $this->validateFields(array($idAccounttype, $idAccountplan, $city), array("Debes seleccionar un tipo de cuenta", "Debes seleccionar un plan de pago, recuerda que tenemos algunos gratuitos", "Debes seleccionar una ciudad"));
             if ($this->saveAccount($account, $accountForm, $userForm)) {
                 if ($this->saveUser($user, $account)) {
                     $file = $_FILES['avatar'];
                     $ext = explode("/", $file['type']);
                     $file['newName'] = "{$user->idUser}.{$ext[1]}";
                     $dir = $this->uploader->user_avatar_dir . "/" . $user->idUser . "/images/avatar/";
                     $uploader = new \Sayvot\Misc\Uploader();
                     $uploader->setExtensionsAllowed(array("png", "jpg", "jpeg"));
                     $uploader->setFile($file);
                     $uploader->setMaxSizeSupported($this->uploader->images_max_size);
                     $uploader->setDir($dir);
                     $uploader->validate();
                     $uploader->upload();
                     if ($this->saveCredential($user, $email, $pass1)) {
                         $this->db->commit();
                         $pe = new \Sayvot\Misc\ParametersEncoder();
                         $link = $pe->encodeLink("account/verify", array($account->idAccount, $user->idUser));
                         $this->flashSession->warning($link);
                         return $this->response->redirect("session/login");
                     }
                 }
             }
         } catch (InvalidArgumentException $ex) {
             $this->flashSession->error($ex->getMessage());
             $this->db->rollback();
         } catch (Exception $ex) {
             $this->db->rollback();
             $this->flashSession->error("Ha ocurrido un error, por favor contacta al administrador");
             $this->logger->log("Exception while creating account: " . $ex->getMessage());
             $this->logger->log($ex->getTraceAsString());
         }
     }
 }
开发者ID:willmontiel,项目名称:sayvot,代码行数:55,代码来源:SessionController.php

示例5: newUserAction

 public function newUserAction()
 {
     $request = $this->get('request');
     $user = new User();
     $userForm = new UserForm($user);
     if ($request->getMethod() === 'POST') {
         $userForm->bind($request);
         if ($userForm->validate()) {
             $user->save();
             return $this->redirect($this->generateUrl('login'));
         }
     }
     $context = array('form' => $userForm);
     return $this->render('', $context);
 }
开发者ID:Everus,项目名称:wbf.test,代码行数:15,代码来源:userController.php

示例6: editAction

 public function editAction($id)
 {
     $account = $this->user->account;
     $editUser = User::findFirst(array("conditions" => "idUser = ?1 AND idAccount = ?2", "bind" => array(1 => $id, 2 => $account->idAccount)));
     if (!$editUser) {
         $this->flashSession->error("El usuario que intenta editar no existe, por favor verifique la información");
         return $this->response->redirect("user/index");
     }
     $this->view->setVar("user", $editUser);
     $editUser->address_user = $editUser->address;
     $editUser->name_user = $editUser->name;
     $editUser->city_user = $editUser->city;
     $editUser->state_user = $editUser->state;
     $editUser->phone_user = $editUser->phone;
     $form = new UserForm($editUser, $this->user->role);
     if ($this->request->isPost()) {
         $form->bind($this->request->getPost(), $editUser);
         $editUser->updated = time();
         $email = strtolower($form->getValue('email'));
         $editUser->email = $email;
         $editUser->name = $this->request->getPost('name_user');
         $editUser->phone = $this->request->getPost('phone_user');
         $editUser->address = $this->request->getPost('address_user');
         $editUser->state = $this->request->getPost('state_user');
         $editUser->city = $this->request->getPost('city_user');
         if ($editUser->save()) {
             $this->flashSession->success('Se ha editado exitosamente el usuario <strong>' . $editUser->userName . '</strong>');
             $this->trace("success", "Se edito un usuario con ID: {$editUser->idUser}");
             return $this->response->redirect("user/index");
         } else {
             foreach ($editUser->getMessages() as $message) {
                 $this->flashSession->error($message);
             }
             $this->trace("fail", "No se edito el usuario con ID: {$editUser->idUser}");
         }
     }
     $this->view->setVar("user", $editUser);
     $this->view->UserForm = $form;
 }
开发者ID:dorianlopez,项目名称:track,代码行数:39,代码来源:UserController.php

示例7: 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

示例8: newuserAction

 public function newuserAction($idAccount)
 {
     $account = Account::findFirst(array('conditions' => 'idAccount = ?1', 'bind' => array(1 => $idAccount)));
     if (!$account) {
         $this->flashSession->error("No se encuentra la cuenta, por favor valide la información");
         return $this->response->redirect("account");
     }
     $user = new User();
     $form = new UserForm($user, $this->user);
     if ($this->request->isPost()) {
         $form->bind($this->request->getPost(), $user);
         $pass1 = $form->getValue('password1');
         $pass2 = $form->getValue('password2');
         $status = $form->getValue('status');
         if ($this->checkPassword($pass1, $pass2)) {
             $user->idAccount = $account->idAccount;
             $user->password = $this->hash->hash($pass1);
             $user->status = $status;
             $user->created = time();
             $user->updated = time();
             if ($form->isValid() && $user->save()) {
                 $this->flashSession->success("Se ha creado el usuario exitosamente");
                 return $this->response->redirect("account/showusers/{$idAccount}");
             }
             foreach ($user->getMessages() as $msg) {
                 $this->flashSession->error($msg->getMessage());
             }
         }
     }
     $this->view->UserForm = $form;
     $this->view->setVar('account', $account);
 }
开发者ID:solutionsCluster,项目名称:silar,代码行数:32,代码来源:AccountController.php

示例9: executeUpdate

 public function executeUpdate($request)
 {
     $object = $this->getRequestParameter('object');
     $user = User::getByApiKey($request->getParameter('login_id'), $request->getParameter('api_key'));
     if (!$user) {
         $output = '<rsp stat="fail"><err code="2" msg="login_id and api_key do not match" /></rsp>';
     } elseif ($object == 'application') {
         $form = new ApplicationForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'description' => $request->getParameter('description'), 'source_url' => $request->getParameter('source_url')));
         if ($form->isValid()) {
             $application = Application::update($form->getValues(), $user);
             if ($application) {
                 $output = '<rsp stat="ok">' . $application->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="4" msg="Unable to update application." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="4" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'comment') {
         $form = new CommentForm();
         $application_id = $module_id = $theme_id = null;
         if ($request->getParameter('application_id')) {
             $application_id = $request->getParameter('application_id');
         }
         if ($request->getParameter('module_id')) {
             $module_id = $request->getParameter('module_id');
         }
         if ($request->getParameter('theme_id')) {
             $theme_id = $request->getParameter('theme_id');
         }
         $form->bind(array('comment' => $request->getParameter('comment'), 'application_id' => $application_id, 'module_id' => $module_id, 'theme_id' => $theme_id));
         if ($form->isValid()) {
             $comment = Comment::update($form->getValues(), $user);
             $output = '<rsp stat="ok">' . $comment->getXML() . '</rsp>';
         } else {
             $output = '<rsp stat="fail"><err code="3" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'module') {
         $form = new ModuleForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'description' => $request->getParameter('description'), 'source_url' => $request->getParameter('source_url'), 'application_id' => $request->getParameter('application_id')));
         if ($form->isValid()) {
             $module = Madule::update($form->getValues(), $user);
             if ($module) {
                 $output = '<rsp stat="ok">' . $module->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="4" msg="Unable to update module." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="4" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'theme') {
         $form = new ThemeForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'description' => $request->getParameter('description')), $request->getFiles());
         if ($form->isValid()) {
             $theme = Theme::update($form->getValues(), $user);
             if ($theme) {
                 $output = '<rsp stat="ok">' . $theme->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="5" msg="Unable to update theme." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="5" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'theme_group') {
         $output = '<rsp stat="fail"><err code="6" msg="This object is not supported for update" /></rsp>';
     } elseif ($object == 'user') {
         $form = new UserForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'password' => $request->getParameter('password'), 'password2' => $request->getParameter('password'), 'email' => $request->getParameter('email'), 'role' => null));
         if ($form->isValid()) {
             $update_user = User::update($form->getValues(), $user);
             if ($update_user) {
                 $output = '<rsp stat="ok">' . $update_user->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="7" msg="Unable to update user." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="7" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     }
     $this->output = $output;
     $this->setTemplate('index');
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:83,代码来源:actions.class.php

示例10: editprofileAction

 public function editprofileAction()
 {
     $user = $this->user;
     $form = new UserForm($user, $this->user);
     if ($this->request->isPost()) {
         $form->bind($this->request->getPost(), $user);
         $user->updated = time();
         if ($form->isValid() && $user->save()) {
             $this->flashSession->success("Se ha editado el usuario exitosamente");
             return $this->response->redirect("user/editprofile");
         }
         foreach ($user->getMessages() as $msg) {
             $this->flashSession->error($msg);
         }
     }
     $this->view->UserForm = $form;
     $this->view->setVar("user", $user);
 }
开发者ID:solutionsCluster,项目名称:silar,代码行数:18,代码来源:UserController.php


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