-1

我正在研究 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);
4

2 回答 2

1

您可能错过了为表单分配操作的部分

$form->setAttribute('method', 'post')
     ->setAttribute('action', $this->url())
     ->prepare();
于 2013-08-29T18:35:17.113 回答
0

尝试做这样的事情(如山姆所说)你需要设置属性

   $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();
于 2013-08-29T21:20:41.623 回答