Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make a locator and get the form insted of injecting the form
  • Loading branch information
harikt committed May 21, 2013
1 parent 6259d11 commit 91b878c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions config/default.php
Expand Up @@ -11,5 +11,8 @@

$di->params['Aura\Framework\Web\Controller\Factory']['map']['contact'] = 'Hari\Contact\Web\Contact\Page';

$di->setter['Hari\Contact\Web\Contact\Page']['setContactForm'] =
$di->lazyNew('Hari\Contact\Web\Forms\ContactForm');
$di->params['Hari\Contact\Locator']['registry'] = [
'hari.contact.contactform' => $di->lazyNew('Hari\Contact\Web\Forms\ContactForm')
];

$di->setter['Hari\Contact\Web\Contact\Page']['setLocator'] = $di->lazyNew('Hari\Contact\Locator');
9 changes: 5 additions & 4 deletions src/Hari/Contact/Web/Contact/Page.php
Expand Up @@ -7,14 +7,15 @@

class Page extends AbstractPage
{
protected $contactForm;
protected $locator;

public function preExec()
{
}

public function actionIndex()
{
$form = $this->contactForm;
$form = $this->locator->get('hari.contact.contactform');
$form->fill($_POST);

if ($this->context->isPost()) {
Expand All @@ -34,8 +35,8 @@ public function actionIndex()
$this->layout = 'default';
}

public function setContactForm($form)
public function setLocator($locator)
{
$this->contactForm = $form;
$this->locator = $locator;
}
}
3 changes: 3 additions & 0 deletions src/Hari/Contact/Web/Contact/views/contact.php
@@ -1,3 +1,6 @@
<?php
$this->title()->set('Contact Us');
?>
<div class="row-fluid">
<div class="span12">Contact Us</div>
</div>
Expand Down

0 comments on commit 91b878c

Please sign in to comment.