我在这里创建自定义元素:ZF2Docs: Advanced use of Forms
1.在Application/Form/Element/CustomElement.php中创建CustomElement类
2.添加到我的Module.php函数
public function getFormElementConfig()
{
return array(
'invokables' => array(
'custom' => 'Application\Form\Element\CustomElement',
),
);
}
如果我使用 FQCN 它工作正常:
$form->add(array(
'type' => 'Application\Form\Element\CustomElement',
'name' => 'myCustomElement'
));
但如果我使用短名称:
$form->add(array(
'type' => 'Custom',
'name' => 'myCustomElement'
));
抛出异常:
Zend\ServiceManager\ServiceManager::get was unable to fetch or create
an instance for Custom