我正在研究zend表单和字段集。我已经创建了表单以及提交按钮。这是代码:
$this->add(array(
'name' => 'submit',
'attributes' => array(
'type' => 'submit',
'value' => 'Search Results',
'id' => 'submit',
'class' => 'submitme',
),
));
我可以在视图侧看到我的所有场景集。但是,我看不到提交按钮。 这是我的控制器文件代码:
$form = $this->getServiceLocator()->get('FormElementManager')->get('Client\Form\Search\SearchForm');
return new ViewModel(array('form' => $form));
最后这是视图的代码:
echo $this->form()->openTag($form);
echo $this->formCollection($form);
echo $this->form()->closeTag($form);
答案 0 :(得分:1)
您可能会错过为表单分配操作的部分
$form->setAttribute('method', 'post')
->setAttribute('action', $this->url())
->prepare();
答案 1 :(得分:0)
尝试做这样的事情(如sam所述)你需要设置属性
$Form = $this->Form;
$Form->setAttribute('action', $this->url('(your route name here)', array('action' => 'add', 'controller' => '(your controller name here)')));
$Form->prepare();
echo $this->form()->openTag($Form);
echo $this->formSubmit($Form->get('any other feilds that you want to see'));
echo $this->formSubmit($Form->get('submit'));
echo $this->form()->closeTag();