Exemplo n.º 1
0
 /**
  * @param ZendForm $form
  * @param boolean  $groupActions
  *
  * @return Form
  */
 public function __invoke(ZendForm $form, $groupActions = false)
 {
     $this->formActionElements = array();
     $form->prepare();
     $this->setElement(new HtmlElement('form'));
     $this->getElement()->setAttributes(array('action' => '', 'method' => 'GET'));
     if (!$form->hasAttribute('id')) {
         $form->setAttribute('id', $form->getName());
     }
     $this->getElement()->addAttributes($form->getAttributes());
     $this->renderElements($form->getIterator(), $groupActions);
     $this->renderFormActions();
     return clone $this;
 }
Exemplo n.º 2
0
 /**
  * Finds action buttons in a form and retruns them
  * @param \Zend\Form\Form $form
  * @return array
  */
 protected function getActions(Form $form)
 {
     //Iterate over all form elements (outside any fieldsets) and find buttons
     $iterator = $form->getIterator();
     $actions = array();
     foreach ($iterator as $element) {
         /* @var $element ElementInterface */
         if ($element instanceof \Zend\Form\FieldsetInterface) {
             //Do not inspect fieldsets
             continue;
         }
         if (in_array($element->getAttribute('type'), array('submit', 'reset', 'button'))) {
             //It is one of the 'button' elements
             $actions[] = $element;
         }
     }
     return $actions;
 }