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


PHP AlbumForm::setInputFilter方法代码示例

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


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

示例1: editAction

 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('album', array('action' => 'add'));
     }
     // Get the Album with the specified id.  An exception is thrown
     // if it cannot be found, in which case go to the index page.
     try {
         $album = $this->getAlbumTable()->getAlbum($id);
     } catch (\Exception $ex) {
         return $this->redirect()->toRoute('album', array('action' => 'index'));
     }
     $form = new AlbumForm();
     $form->bind($album);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getAlbumTable()->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return array('id' => $id, 'form' => $form);
 }
开发者ID:rajeebsaraswati,项目名称:zf2-busodisa,代码行数:28,代码来源:AlbumController.php

示例2: editAction

 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('album', array('action' => 'add'));
     }
     $album = $this->getEntityManager()->find('Album\\Entity\\Album', $id);
     if (!$album) {
         return $this->redirect()->toRoute('album', array('action' => 'index'));
     }
     $form = new AlbumForm();
     $form->bind($album);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getEntityManager()->flush();
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return array('id' => $id, 'form' => $form);
 }
开发者ID:Armin-Smailzade,项目名称:album-zf2-doctrine-php,代码行数:25,代码来源:AlbumController.php

示例3: editAction

 /**
  * Edit Action
  * <br/> Used to Edit Exists Album
  * @return ViewModel edit view
  */
 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('album', array('action' => 'add'));
     }
     // Get the album with the specified id.
     // An Exception is thrown if it connot be found, in which case go to index page
     try {
         $album = $this->getAlbumTable()->getAlbum($id);
     } catch (\Exception $e) {
         return $this->redirect()->toRoute('album', array('action' => 'index'));
     }
     $form = new AlbumForm();
     $form->bind($album);
     $form->get('submit')->setAttribute('value', 'Edit');
     // Or also can change Submit button value using setValue() method like into AddAction
     // $form->get('submit')->setValue('Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getAlbumTable()->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return new ViewModel(array('id' => $id, 'form' => $form));
 }
开发者ID:ahmed-hamdy90,项目名称:build_web_app_using_Zend_2,代码行数:35,代码来源:AlbumController.php

示例4: createService

 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $options = $this->getOptions($serviceLocator)->toArray();
     $form = new AlbumForm('album', $options);
     $form->setHydrator(new ClassMethods())->setObject(new AlbumEntity());
     $form->setInputFilter(new AlbumFilter());
     return $form;
 }
开发者ID:omusico,项目名称:cursoZf2,代码行数:8,代码来源:AlbumFormFactory.php

示例5: update

 public function update($id, $data)
 {
     $data['id'] = $id;
     $album = $this->getAlbumTable()->getAlbum($id);
     $form = new AlbumForm();
     $form->bind($album);
     $form->setInputFilter($album->getInputFilter());
     $form->setData($data);
     if ($form->isValid()) {
         $id = $this->getAlbumTable()->saveAlbum($form->getData());
     }
     return $this->get($id);
 }
开发者ID:ptcampos,项目名称:angular-zf2-rest,代码行数:13,代码来源:AlbumRestController.php

示例6: update

 public function update($id, $data)
 {
     $data['id'] = $id;
     $album = $this->getAlbumTable()->getAlbum($id);
     $form = new AlbumForm();
     $form->bind($album);
     $form->setInputFilter($album->getInputFilter());
     $form->setData($data);
     if ($form->isValid()) {
         $id = $this->getAlbumTable()->saveAlbum($form->getData());
         return new JsonModel(array('code' => 0, 'ret' => $this->get($id)));
     } else {
         return new JsonModel(array('code' => -1, 'ret' => 'invalid'));
     }
 }
开发者ID:idwsdta,项目名称:ZF2_resftFull_mobile_frameworks,代码行数:15,代码来源:AlbumRestApiController.php

示例7: addAction

 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setValue('add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getAlbumTable()->saveAlbum($album);
             return $this->redirect()->toRoute('album');
         }
     }
     return array('form' => $form);
 }
开发者ID:brunomrpx,项目名称:seeds,代码行数:17,代码来源:AlbumController.php

示例8: addAction

 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setAttribute('value', 'Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->post());
         if ($form->isValid()) {
             $album->populate($form->getData());
             $this->getAlbumTable()->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return array('form' => $form);
 }
开发者ID:robertbasic,项目名称:zf2-tutorial,代码行数:18,代码来源:AlbumController.php

示例9: addAction

 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->populate($form->getData());
             $this->getEntityManager()->persist($album);
             $this->getEntityManager()->flush();
             return $this->redirect()->toRoute('album');
         }
     }
     return array('form' => $form);
 }
开发者ID:noikiy,项目名称:zend_test,代码行数:18,代码来源:AlbumController.php

示例10: addAction

 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setAttribute('label', 'Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getEntityManager()->persist($album);
             $this->getEntityManager()->flush();
             // Redirect to list of albums
             return $this->redirect()->toRoute('dalbum');
         }
     }
     return array('form' => $form);
 }
开发者ID:seyfer,项目名称:zend2-tutorial.me,代码行数:19,代码来源:IndexController.php

示例11: addAction

 public function addAction()
 {
     $viewModel = $this->getViewModel();
     $form = new AlbumForm();
     $form->get('submit')->setAttribute('value', 'Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getAlbumTable()->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album-front-album');
         }
     }
     return $viewModel->setVariables(array('form' => $form));
 }
开发者ID:ashimidashajia,项目名称:zendstore,代码行数:19,代码来源:AlbumController.php

示例12: editAction

 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     //Get the id from url parmas
     if (!$id) {
         return $this->redirect()->toRoute('album', array('action' => 'add'));
         //Wheather id is null then redirect to add function
     }
     try {
         $album = $this->getAlbumTable()->getAlbum($id);
         //get the album data of that particular id
     } catch (Exception $e) {
         return $this->redirect()->toRoute('album', array('action' => 'add'));
     }
     $form = new AlbumForm();
     //Create a Instance of AlbumForm
     $form->bind($album);
     //Bind the album data to the form
     $form->get('submit')->setAttribute('value', 'Edit');
     //Change submit to Edit Button
     $request = $this->getRequest();
     //Generate Request
     if ($request->isPost()) {
         //check wheather request is POST or Not
         $album = new Album();
         //create a instance of Album Model
         $form->setInputFilter($album->getInputFilter());
         //Validation filter set of type album on form
         $form->setData($request->getPost());
         //set data on form
         if ($form->isValid()) {
             //Check wheather form data is valid or not
             $this->getAlbumTable()->saveAlbum($form->getData());
             //Save updated data from form
             //Redirect to list of album
             return $this->redirect()->toRoute('album');
         }
     }
     return array('id' => $id, 'form' => $form);
 }
开发者ID:umangvarshney,项目名称:zendtest,代码行数:40,代码来源:AlbumController.php

示例13: editAction

 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('album', array('action' => 'add'));
     }
     $album = $this->getAlbumTable()->getAlbum($id);
     //var_dump($album); die;
     $form = new AlbumForm();
     $form->bind($album);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getAlbumTable()->saveAlbum($this->getRequest()->getPost()->toArray());
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return array('id' => $id, 'form' => $form, 'role' => $this->zfcUserAuthentication()->getIdentity()->getRole());
 }
开发者ID:silaunosti,项目名称:magazin.ua,代码行数:23,代码来源:AlbumController.php

示例14: editAction

 public function editAction()
 {
     $auth = new AuthenticationService();
     $acl = $this->getAcl();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('album', array('action' => 'login'));
     }
     if (!$acl->isAllowed($this->getRole(), null, 'edit')) {
         return $this->redirect()->toRoute('album', array('action' => 'index'));
     }
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('album', array('action' => 'add'));
     }
     // Get the Album with the specified id.  An exception is thrown
     // if it cannot be found, in which case go to the index page.
     try {
         $album = $this->getAlbumTable()->getAlbum($id);
     } catch (\Exception $ex) {
         return $this->redirect()->toRoute('album', array('action' => 'index'));
     }
     $form = new AlbumForm();
     $form->bind($album);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($request->getPost('submit2')) {
             return $this->redirect()->toRoute('album');
         }
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getAlbumTable()->saveAlbum($album);
             $form->get('title')->setAttribute('value', $request->getPost('title'));
             $form->get('artist')->setAttribute('value', $request->getPost('artist'));
             $notification = array('title' => $request->getPost('title'), 'artist' => $request->getPost('artist'));
         }
     }
     return array('id' => $id, 'form' => $form, 'notification' => $notification);
 }
开发者ID:anshp,项目名称:new,代码行数:40,代码来源:AlbumController.php

示例15: editAction

 public function editAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('album', array('action' => 'add'));
     }
     $resp = $this->getRestResponse(sprintf($this->domain . "/album-rest/%s", $id));
     $respData = Json::decode($resp->getBody());
     $album = new Album();
     $album->exchangeArray(get_object_vars($respData->album));
     $form = new AlbumForm();
     $form->bind($album);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $resp = $this->getRestResponse(sprintf($this->domain . "/album-rest/%s", $id), "POST", get_object_vars($form->getData()));
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     $model = new ViewModel(array('id' => $id, 'form' => $form));
     //         $model->setTemplate("album/album/edit.phtml");
     return $model;
 }
开发者ID:omusico,项目名称:cursoZf2,代码行数:27,代码来源:AlbumClientController.php


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