當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Form\AlbumForm類代碼示例

本文整理匯總了PHP中Album\Form\AlbumForm的典型用法代碼示例。如果您正苦於以下問題:PHP AlbumForm類的具體用法?PHP AlbumForm怎麽用?PHP AlbumForm使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AlbumForm類的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, $this->getUserId());
     } catch (\Exception $ex) {
         return $this->redirect()->toRoute('album', array('action' => 'index'));
     }
     $form = new AlbumForm();
     $form->bind($album);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $this->getAlbumTable()->saveAlbum($album, $this->getUserId());
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     $this->layout()->setVariable('header_title', 'Editer un album');
     return array('id' => $id, 'form' => $form);
 }
開發者ID:Embraser01,項目名稱:IUT-ProjetWeb-TP1,代碼行數: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'));
     }
     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);
             return $this->redirect()->toRoute('album');
         }
     }
     return array('id' => $id, 'form' => $form);
 }
開發者ID:obsidianstorms,項目名稱:zendtraining,代碼行數:25,代碼來源:AlbumController.php

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

示例4: editAction

 public function editAction()
 {
     $id = $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()) {
             $album->exchangeArray($form->getData());
             $this->getAlbumTable()->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     } else {
         $form->bind($album);
     }
     return array('id' => $id, 'form' => $form);
 }
開發者ID:pasechnik,項目名稱:mongozend,代碼行數:31,代碼來源:AlbumController.php

示例5: editAction

 public function editAction()
 {
     $id = (int) $this->params('id');
     if (!$id) {
         return $this->redirect()->toRoute('album', array('action' => 'add'));
     }
     $album = $this->getAlbumTable()->getAlbum($id);
     $form = new AlbumForm();
     $form->bind($album);
     $form->get('submit')->setAttribute('value', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $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:jewelhuq,項目名稱:zf2-tutorial,代碼行數:21,代碼來源:AlbumController.php

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

示例7: editAction

 public function editAction()
 {
     $form = new AlbumForm();
     $form->submit->setLabel('Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $formData = $request->post()->toArray();
         if ($form->isValid($formData)) {
             $id = $form->getValue('id');
             $artist = $form->getValue('artist');
             $title = $form->getValue('title');
             if ($this->albums->getAlbum($id)) {
                 $this->albums->updateAlbum($id, $artist, $title);
             }
             // Redirect to list of albums
             return $this->redirectToList();
         }
     } else {
         $id = $request->query()->get('id', 0);
         if ($id > 0) {
             $form->populate($this->albums->getAlbum($id));
         }
     }
     return array('form' => $form);
 }
開發者ID:nsenkevich,項目名稱:zf2-tutorial,代碼行數:25,代碼來源:AlbumController.php

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

示例9: editAction

 public function editAction()
 {
     $id = (int) $this->getEvent()->getRouteMatch()->getParam('id');
     if (!$id) {
         return $this->redirect()->toRoute('dalbum', array('action' => 'add'));
     }
     $album = $this->getEntityManager()->find('Album\\Entity\\Album', $id);
     $form = new AlbumForm();
     $form->setBindOnValidate(false);
     $form->bind($album);
     $form->get('submit')->setAttribute('label', 'Edit');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $form->bindValues();
             $this->getEntityManager()->flush();
             // Redirect to list of albums
             return $this->redirect()->toRoute('dalbum');
         }
     }
     return array('id' => $id, 'form' => $form);
 }
開發者ID:seyfer,項目名稱:zend2-tutorial.me,代碼行數:23,代碼來源:IndexController.php

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

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

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

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

示例14: 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()) {
             // Perform album validation
             if ($form->isValidAlbum($album)) {
                 // If the album passes validation then save it
                 $this->getAlbumTable()->saveAlbum($album);
             } else {
                 // Album did not pass validation!
                 // Post message to user, album not allowed!
                 // TODO: Add message to user did not pass validation.
             }
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return array('id' => $id, 'form' => $form);
 }
開發者ID:justintime4tea,項目名稱:ZendFramework2_AlbumModule,代碼行數:36,代碼來源:AlbumController.php

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


注:本文中的Album\Form\AlbumForm類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。