Пример #1
0
 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);
 }