我没有使用完整的 ZF2 安装,只有我指定的模块,包括zendframework/zend-form
从表单选择:
use Zend\Form\Element;
$element = new Element\Select('language');
$element->setValueOptions(array(
'0' => 'French',
//...
'3' => 'Chinese'
));
echo $this->formSelect($element);
问题:
在非视图 PHP 中时:
PHP error: Call to undefined method formSelect()
在 *.phtml 视图文件中时:
Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException'
with message 'Zend\View\HelperPluginManager::get was unable to fetch
or create an instance for formselect'
笔记:
$this->partial()
工作,一样$this->escapehtml()
,但$this->formselect()
不