$userId = $this->getUser()->getGuardUser()->getId();
$this->form = new AdForm(null, array('company_user_id' => CompanyTable::getInstance()->findOneByUserId($userId)->getId()));
+ $this->page = $request->getParameter('page', 1);
}
public function executeCreate(sfWebRequest $request)
$this->form = new AdForm($adInit, array('company_user_id' => $companyUserId));
+ $this->page = $request->getParameter('page', 1);
+
$this->processForm($request, $this->form);
$this->setTemplate('new');
$this->forward404Unless($companyId == $companyUserId, sprintf('Ad does not exist (%s).', $request->getParameter('id')));
+ $this->page = $request->getParameter('page', 1);
+
$this->form = new AdForm($ad, array('company_user_id' => $companyUserId));
}
$this->form = new AdForm($ad, array('company_user_id' => $companyUserId));
+ $this->page = $request->getParameter('page', 1);
+
$this->processForm($request, $this->form);
$this->setTemplate('edit');
<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
-<form action="<?php echo url_for('ad/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+<form action="<?php echo url_for('ad/'.($form->getObject()->isNew() ? 'create' : 'update').'?page='.$page.(!$form->getObject()->isNew() ? '&id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
<tr>
<td colspan="2">
<?php echo $form->renderHiddenFields(false) ?>
- <a href="<?php echo url_for('ad/index') ?>">Back to list</a>
+ <a href="<?php echo url_for('ad/index?page='.$page) ?>"><?php echo __('Back to list') ?></a>
<input type="submit" value="Update" />
</td>
</tr>
<h2><?php echo __('Edit Ad') ?></h2>
-<?php include_partial('form', array('form' => $form)) ?>
+<?php include_partial('form', array('form' => $form, 'page' => $page)) ?>
</table>
</form>
-<?php include_partial('ad/list', array('ads' => $pager->getResults(), 'userLanguageId' => $userLanguageId)) ?>
+<?php if ($pager->haveToPaginate()): ?>
+ <?php include_partial('ad/list', array('ads' => $pager->getResults(), 'userLanguageId' => $userLanguageId, 'page' => $pager->getPage())) ?>
+<?php else: ?>
+ <?php include_partial('ad/list', array('ads' => $pager->getResults(), 'userLanguageId' => $userLanguageId, 'page' => '1')) ?>
+<?php endif; ?>
+
<?php if ($pager->haveToPaginate()): ?>
<div class="pagination">
</div>
<?php endif; ?>
- <a href="<?php echo url_for('ad/new') ?>" class="bt_green"><span class="bt_green_lft"></span><strong><?php echo __('New Ad') ?></strong><span class="bt_green_r"></span></a>
+<?php if ($pager->haveToPaginate()): ?>
+ <a href="<?php echo url_for('ad/new?page='.$pager->getPage()) ?>" class="bt_green"><span class="bt_green_lft"></span><strong><?php echo __('Create new Ad') ?></strong><span class="bt_green_r"></span></a>
+<?php else: ?>
+ <a href="<?php echo url_for('ad/new?page=1') ?>" class="bt_green"><span class="bt_green_lft"></span><strong><?php echo __('Create new Ad') ?></strong><span class="bt_green_r"></span></a>
+<?php endif; ?>
<h2><?php echo __('New Ad') ?></h2>
-<?php include_partial('form', array('form' => $form)) ?>
+<?php include_partial('form', array('form' => $form, 'page' => $page)) ?>