[英]How I can use custom view helper for form in Zend Framework 1?
[英]How do I use a view helper inside a form in zend framework 2?
我有一个视图助手,它返回一个名为$this->getTypes();
的数组$this->getTypes();
我将其设置为可调用的:
'view_helpers' => array(
'invokables' => array(
'getTypes' => 'Account\View\Helper\GetTypes',
),
),
如果我在视图中回显它,则可以看到该数组,但是在形式上却失败了。
我想要类似的东西:
$this->add(array(
'name' => 'type_id',
'type' => 'Zend\Form\Element\Select',
'attributes' => array(
'required' => 'required',
),
'options' => array(
'label' => 'Type *',
'value_options' => $this->getTypes(),
),
));
有任何想法吗?
简短的答案是: 您不会
中等答案是:要将DB值放入Zend\\Form\\Element\\Select
您必须将DB- / Service-Layer注入到表单中。
长答案是:写在我的博客文章Zend\\Form\\Element\\Select
和数据库值中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.