Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ZF2 Zend\Form\FormElementManager::get无法获取或创建Zend\Form\Element\Datetime的实例_Php_Forms_Datetime_Zend Framework2 - Fatal编程技术网

Php ZF2 Zend\Form\FormElementManager::get无法获取或创建Zend\Form\Element\Datetime的实例

Php ZF2 Zend\Form\FormElementManager::get无法获取或创建Zend\Form\Element\Datetime的实例,php,forms,datetime,zend-framework2,Php,Forms,Datetime,Zend Framework2,当我在测试域的窗体类中运行以下代码时: $dateformat = "Y-m-d H:i"; $this->add(array( 'name' => 'startdatetime', 'type' => 'Zend\Form\Element\Datetime', 'attributes' => array( 'id' => 'startdatetime', 'data-format' => "YYYY-M

当我在测试域的窗体类中运行以下代码时:

$dateformat = "Y-m-d H:i";
$this->add(array(
    'name' => 'startdatetime',
    'type' => 'Zend\Form\Element\Datetime',
    'attributes' => array(
        'id' => 'startdatetime',
        'data-format' => "YYYY-MM-DD HH:mm",
        'min' => date($dateformat, $nowdate),
        'max' => date($dateformat, $futuredate),
        'step' => '5', // minutes; default step interval is 1 mint
    ),
    'options' => array(
        'label' => _('Start date and time'),
        'help-block' => _('Enter start date and time (YYYY-MM-DD HH:MM)'),
    ),
));
$this->get('startdatetime')->setFormat($dateformat);
我得到这个错误:

Zend\Form\FormElementManager::get was unable to fetch or create an instance for Zend\Form\Element\Datetime
在本地运行时,没有错误,一切正常吗? 此外,文本和Textarea构成它前面的元素,工作正常

我只是不能把我的头绕在它周围。。。 有什么想法吗

提前感谢

日期时间元素。您还可以使用类的完全限定类名,它当然区分大小写,
Zend\Form\Element\DateTime

因此,您需要做的唯一更改是在
Datetime

'type' => 'Zend\Form\Element\DateTime',
或者使用实际的服务名称,与所有服务一样,该名称不区分大小写


谢谢完全错过了。
'type' => 'datetime',