Zend framework2 Zend Framework 2编辑日期

Zend framework2 Zend Framework 2编辑日期,zend-framework2,Zend Framework2,我读了这本书,当然,我试着做一些例子。 但当我编辑日期时,收到以下错误消息: 发生了一个错误 执行过程中发生错误;请稍后再试。 其他信息: Zend\ServiceManager\Exception\ServiceNotFoundException 文件: 信息: Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for UserEditForm 堆栈跟踪: #0 C:\wamp\

我读了这本书,当然,我试着做一些例子。 但当我编辑日期时,收到以下错误消息:

发生了一个错误 执行过程中发生错误;请稍后再试。 其他信息: Zend\ServiceManager\Exception\ServiceNotFoundException

文件:

信息:

Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for UserEditForm
堆栈跟踪:

#0 C:\wamp\www\zend2book\module\Users\src\Users\Controller\UserManagerController.php(34): Zend\ServiceManager\ServiceManager->get('UserEditForm')
#1 C:\wamp\www\zend2book\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractActionController.php(83): Users\Controller\UserManagerController->editAction()
#2 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#3 C:\wamp\www\zend2book\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#4 C:\wamp\www\zend2book\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#5 C:\wamp\www\zend2book\vendor\zendframework\zendframework\library\Zend\Mvc\Controller\AbstractController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#6 C:\wamp\www\zend2book\vendor\zendframework\zendframework\library\Zend\Mvc\DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#7 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#8 C:\wamp\www\zend2book\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#9 C:\wamp\www\zend2book\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#10 C:\wamp\www\zend2book\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(309): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#11 C:\wamp\www\zend2book\public\index.php(17): Zend\Mvc\Application->run()
#12 {main}
这是我从控制器执行的编辑操作:

 public function editAction()
{
$this->layout('layout/myaccount');

$userTable = $this->getServiceLocator()->get('UserTable');

$user = $userTable->getUser($this->params()->fromRoute('id'));
$form = $this->getServiceLocator()->get('UserEditForm');
$form->bind($user);
$viewModel = new ViewModel(array('form' => $form, 'user_id' => $this->params()->fromRoute('id')));
return $viewModel;
}
我的表格代码

<?php
// filename : module/Users/src/Users/Form/RegisterForm.php
namespace Users\Form;

use Zend\Form\Form;

class UserEditForm extends Form
{
    public function __construct($name = null)
    {
        parent::__construct('Edit User');
        $this->setAttribute('method', 'post');
        $this->setAttribute('enctype','multipart/form-data');

        $this->add(array(
            'name' => 'id',
            'attributes' => array(
                'type'  => 'hidden',
            ),
        ));

        $this->add(array(
            'name' => 'name',
            'attributes' => array(
                'type'  => 'text',
                'required' => 'required'                                 
            ),
            'options' => array(
                'label' => 'Full Name',
            ),
        ));


        $this->add(array(
            'name' => 'email',
            'attributes' => array(
                'type'  => 'email',
                'required' => 'required'                 
            ),
            'options' => array(
                'label' => 'Email',
            ),
        )); 

        $this->add(array(
            'name' => 'submit',
            'attributes' => array(
                'type'  => 'submit',
                'value' => 'Save'
            ),
        )); 
    }
}

它找不到
UserEditForm
。 很可能您没有在service manager配置中定义它的位置。 确保你定义了

'service_manager' => array (
        'invokables' => array (
            'UserEditForm' => 'Users\Form\RegisterForm' 
        ), 
)
'service_manager' => array (
        'invokables' => array (
            'UserEditForm' => 'Users\Form\RegisterForm' 
        ), 
)