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


PHP UserForm::setAction方法代码示例

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


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

示例1: editAction

 public function editAction()
 {
     $record = null;
     $photoFilename = null;
     $userId = $this->_request->getParam('id');
     if (!empty($userId)) {
         $record = My_Model::get('Users')->getById($userId);
         if (!$record) {
             throw new Zend_Controller_Action_Exception('The requested page does not exist', 404);
         }
         $this->view->userId = $userId;
     }
     $form = new UserForm();
     $form->setAction($this->_helper->url->url());
     if ($record === null) {
         $this->view->title = 'Add User';
     } else {
         $this->view->title = 'Edit User';
         $form->setModifyMode();
     }
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $formValues = $form->getValues();
             $foundUser = My_Model::get('Users')->fetchRow(array("username = ?" => $formValues["username"]));
             if ($foundUser != null && $foundUser->getId() != $userId) {
                 $form->getElement('username')->addError('This username is taken');
                 $form->markAsError();
                 return;
             }
             //XXX: Je to dobytčárna
             if ($form->photo->receive()) {
                 $photo = $form->photo;
                 $oldFullPath = $photo->getFileName();
                 $path_parts = pathinfo($oldFullPath);
                 if ($path_parts) {
                     $photoFilename = $photo->getHash('md5') . '.' . $path_parts['extension'];
                     $newFullPath = $path_parts['dirname'] . '/' . $photoFilename;
                     rename($oldFullPath, $newFullPath);
                 }
             }
             if ($record === null) {
                 $record = My_Model::get('Users')->createRow();
                 if ($photoFilename) {
                     $record->setPhotoFilename($photoFilename);
                 }
                 $record->updateFromArray($formValues, true);
             } else {
                 if ($photoFilename) {
                     $record->setPhotoFilename($photoFilename);
                 }
                 $record->updateFromArray($formValues, false);
                 //do not update created on value
             }
             //Zend_Debug::dump($formValues);
             //echo '================================================================<br />';
             //Zend_Debug::dump($formValues);
             //echo '========================PHOTO=========================<br />';
             //$var = file_get_contents($form->photo);
             //Zend_Debug::dump($var);
             $this->_helper->flashMessenger->setNamespace("success")->addMessage("Your changes have been saved!");
             $this->_helper->redirector->gotoRoute(array('controller' => 'user'), 'default', true);
         }
     } else {
         if ($record !== null) {
             $form->populate($record->toArray());
         }
     }
 }
开发者ID:cngroupdk,项目名称:InterviewMe_Tym3,代码行数:69,代码来源:UserController.php


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