本文整理汇总了PHP中Album\Form\AlbumForm::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP AlbumForm::getData方法的具体用法?PHP AlbumForm::getData怎么用?PHP AlbumForm::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album\Form\AlbumForm
的用法示例。
在下文中一共展示了AlbumForm::getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
// 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('form' => $form);
}
示例2: 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);
}
示例3: addAction
public function addAction()
{
$form = new AlbumForm();
// 56
$form->get('submit')->setValue('Add');
// 57
$request = $this->getRequest();
if ($request->isPost()) {
// 58
$album = new Album();
$form->setInputFilter($album->getInputFilter());
// 59
$form->setData($request->getPost());
// 60
if ($form->isValid()) {
// 61
$album->exchangeArray($form->getData());
// 62
$this->getAlbumTable()->saveAlbum($album);
// 63
// Redirect to list of albums
return $this->redirect()->toRoute('album');
// 64
}
}
return array('form' => $form);
// 65
}
示例4: 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);
}
示例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 new JsonModel(array('code' => 0, 'ret' => $this->get($id)));
} else {
return new JsonModel(array('code' => -1, 'ret' => 'invalid'));
}
}
示例6: 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);
}
示例7: addAction
public function addAction()
{
$form = new AlbumForm();
$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, $this->getUserId());
// Redirect to list of albums
return $this->redirect()->toRoute('album');
}
}
$this->layout()->setVariable('header_title', 'Ajouter un Album');
return array('form' => $form);
}
示例8: 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);
}
示例9: addAction
public function addAction()
{
$form = new AlbumForm();
$form->get('submit')->setValue('Add');
$request = $this->getRequest();
if ($request->isPost()) {
$album = new Album();
$this->db = $this->getServiceLocator()->get('Album\\Mapper\\AlbumDataMapper');
$form->setInputFilter($album->getInputFilter());
$form->setData($request->getPost());
if ($form->isValid()) {
$album->exchangeArray($form->getData());
$this->db->saveAlbum($album);
// Redirect to list of albums
return $this->redirect()->toRoute('album');
}
}
return array('form' => $form);
}
示例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);
}
示例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));
}
示例12: addAction
public function addAction()
{
$form = new AlbumForm();
$form->get('submit')->setValue('Add');
$form->get('title')->setAttribute('class', 'form-control');
$form->get('artist')->setAttribute('class', 'form-control');
$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');
}
}
return array('form' => $form);
}
示例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);
}
示例14: 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);
$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($form->getData());
// Redirect to list of albums
return $this->redirect()->toRoute('album');
}
}
return array('id' => $id, 'form' => $form);
}
示例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;
}