本文整理汇总了PHP中Album\Form\AlbumForm::isValidAlbum方法的典型用法代码示例。如果您正苦于以下问题:PHP AlbumForm::isValidAlbum方法的具体用法?PHP AlbumForm::isValidAlbum怎么用?PHP AlbumForm::isValidAlbum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album\Form\AlbumForm
的用法示例。
在下文中一共展示了AlbumForm::isValidAlbum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()) {
// 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);
}