Created
January 9, 2016 19:33
-
-
Save alihammad-gist/e36b3587baa0364f4ae7 to your computer and use it in GitHub Desktop.
Factory not being found by FormElementManager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Catchable fatal error: Argument 1 passed to Ticker\Form\TickerFieldset::__construct() | |
must implement interface Zend\Stdlib\Hydrator\HydratorInterface, none given, called in | |
../vendor/zendframework/zend-form/src/FormElementManager.php on line 174 | |
and defined in /Ticker/Form/TickerFieldset.php on line 11 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
'service_manager' => [ | |
'invokables' => [ | |
'Ticker\Form\Form' => 'Ticker\Form\Form', | |
'Ticker\Hydrator\TickerHydrator' => 'Ticker\Hydrator\TickerHydrator', | |
], | |
'factories' => [ | |
'Ticker\Table\TickerTable' => 'Ticker\Table\Factory\TickerTableFactory', | |
'Ticker\Service\TickerService' => 'Ticker\Service\Factory\TickerServiceFactory', | |
], | |
], | |
'form_elements' => [ | |
'factories' => [ | |
'Ticker\Form\TickerFieldset' => 'Ticker\Form\Factory\TickerFieldsetFactory', | |
] | |
], | |
'view_manager' => [ | |
'template_map' => [ | |
'ticker/admin/index' => __DIR__ . '/../view/ticker/admin/index.phtml', | |
'ticker/admin/add' => __DIR__ . '/../view/ticker/admin/add.phtml', | |
] | |
], | |
'view_helpers' => [ | |
'invokables' => [ | |
'tickerMenu' => 'Ticker\View\Helper\TickerMenu', | |
] | |
], | |
'router' => [ | |
'routes' => [ | |
'zfcadmin' => [ | |
'child_routes' => [ | |
'ticker' => [ | |
'type' => 'literal', | |
'options' => [ | |
'route' => '/ticker', | |
'defaults' => [ | |
'controller' => 'Ticker\Controller\Admin', | |
'action' => 'index' | |
] | |
], | |
'may_terminate' => true, | |
'child_routes' => [ | |
'add' => [ | |
'type' => 'literal', | |
'options' => [ | |
'route' => '/add', | |
'defaults' => [ | |
'controller' => 'Ticker\Controller\Admin', | |
'action' => 'add', | |
] | |
] | |
] | |
] | |
] | |
] | |
] | |
] | |
], | |
'controllers' => [ | |
'factories' => [ | |
'Ticker\Controller\Admin' => 'Ticker\Controller\Factory\Admin', | |
] | |
], | |
'navigation' => [ | |
'admin' => [ | |
'ticker' => [ | |
'label' => 'Tickers', | |
'route' => 'zfcadmin/ticker' | |
] | |
], | |
'tickeradmin' => [ | |
'list' => [ | |
'label' => 'List Tickers', | |
'route' => 'zfcadmin/ticker', | |
], | |
'add' => [ | |
'label' => 'Add/Edit Ticker', | |
'route' => 'zfcadmin/ticker/add', | |
] | |
] | |
] | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Ticker\Form\Factory; | |
use Ticker\Form\TickerFieldset; | |
use Zend\ServiceManager\ServiceLocatorInterface; | |
// lives in FormElementManager | |
class TickerFieldsetFactory | |
{ | |
public function __invoke(ServiceLocatorInterface $sm) | |
{ | |
die('Reading TickerFieldsetFactory now'); | |
$hydrator = $sm->getServiceLocator()->get('Ticker\Hydrator\TickerHydrator'); | |
return new TickerFieldset($hydrator); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Ticker\Form; | |
use Zend\Form\Form as BaseForm; | |
class Form extends BaseForm | |
{ | |
public function __construct($name = 'ticker-form', $options = ['method' => 'POST']) | |
{ | |
parent::__construct($name, $options); | |
$this->add([ | |
'type' => 'Ticker\Form\TickerFieldset', // <-- | |
]); | |
$this->add([ | |
'name' => 'save', | |
'type' => 'submit', | |
'attributes' => [ | |
'value' => 'Save', | |
] | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment