/** * Display a Form * * @param \Zend\Form\Form $form * @return string */ public function __invoke(ZendForm $form) { $form->prepare(); $html = $this->getFormHelper()->openTag($form); $html .= $this->render($form->getIterator()); return $html . $this->getFormHelper()->closeTag(); }
/** * Outputs message depending on flag * * @return string */ public function __invoke(Form $form, $url, $class = 'form-horizontal') { $form->setAttribute('action', $url); $form->setAttribute('class', $class); $form->prepare(); $output = $this->getView()->form()->openTag($form); $submitElements = array(); foreach ($form as $element) { if ($element instanceof Submit) { $submitElements[] = $element; } elseif ($element instanceof Csrf || $element instanceof Hidden) { $output .= $this->getView()->formElement($element); } else { $element->setLabelAttributes(array('class' => 'control-label')); $output .= '<div class="control-group">'; $output .= $this->getView()->formLabel($element); $output .= '<div class="controls">'; $output .= $this->getView()->formElement($element); $output .= $this->getView()->formElementErrors($element); $output .= '</div>'; $output .= '</div>'; } } $output .= '<div class="form-actions">'; foreach ($submitElements as $element) { $output .= $this->getView()->formElement($element) . ' '; } $output .= '</div>'; $output .= $this->getView()->form()->closeTag(); return $output; }
public function __invoke(Form $form, $action) { $form->setAttribute('method', 'post'); $form->setAttribute('action', $action); $form->prepare(); $view = $this->getView(); $html = ''; $html .= $view->form()->openTag($form); $html .= '<table class="default-table">'; $formElements = $form->getElements(); foreach ($formElements as $formElement) { if ($formElement instanceof Checkbox) { $html .= $view->formRowCheckbox($form, $formElement); } else { if ($formElement instanceof Submit) { $html .= $view->formRowSubmit($form, $formElement); } else { $html .= $view->formRowDefault($form, $formElement); } } } $html .= '</table>'; $html .= $view->form()->closeTag(); return $html; }
public function testResetPasswordValueIfFormIsNotValid() { $this->form->add(array('type' => 'Zend\\Form\\Element\\Password', 'name' => 'password')); $this->form->add(array('type' => 'Zend\\Form\\Element\\Email', 'name' => 'email')); $this->form->setData(array('password' => 'azerty', 'email' => 'wrongEmail')); $this->assertFalse($this->form->isValid()); $this->form->prepare(); $this->assertEquals('', $this->form->get('password')->getValue()); }
public function prepare() { if ($this->isPrepared) { return $this; } $email = new Email('email'); $email->setLabel('Email'); $password = new Password('password'); $password->setLabel('Password'); $submit = new Submit('login'); $submit->setValue('Login'); $this->add($email)->add($password)->add($submit); return parent::prepare(); }
/** * @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; }
/** * Outputs message depending on flag * * @return string */ public function __invoke(Form $form) { $form->prepare(); $output = $this->getView()->form()->openTag($form); foreach ($form as $element) { $output .= $this->renderElement($element); } $output .= '<div class="form-group"><div class="col-sm-2"></div><div class="col-sm-2">'; foreach ($this->submitElements as $element) { $element->setAttribute('class', 'form-control btn-primary btn-lg'); $output .= $this->getView()->formElement($element) . ' '; } $output .= '</div></div>'; $output .= $this->getView()->form()->closeTag(); return $output; }
public function prepare() { if ($this->isPrepared) { return $this; } $email = new Email('email'); $email->setLabel('Email'); $password = new Password('password'); $password->setLabel('P2assword'); $member = new Radio('memberOf'); $member->setValueOptions(array('__model.id__' => '__model.name__')); $memberOfTemplate = new TemplateCollection('memberOfTemplate'); $memberOfTemplate->setTargetElement($member); $memberOf = new Fieldset('memberOfGroup'); $memberOf->setLabel('Member of')->add($memberOfTemplate); $submit = new Submit('register'); $submit->setValue('Register'); $this->add($memberOf)->add($submit); return parent::prepare(); }
public function prepare() { parent::prepare(); return $this; }
document.getElementById('pg-text-2').innerHTML = 'Upload done'; } </script> </head> <body> <?php $file = new Element\File('file'); $file->setLabel('File'); $progress_key = new Element\Hidden('progress_key'); $progress_key->setAttribute('id', 'progress_key'); $progress_key->setValue(md5(uniqid(rand()))); $submit = new Element\Submit('submit'); $submit->setValue('Upload!'); $form = new Form("ZendForm"); $form->setAttributes(array('enctype' => 'multipart/form-data', 'action' => 'ZendForm.php', 'target' => 'uploadTarget', 'onsubmit' => 'observeProgress();')); $form->prepare(); $formhelper = new Helper\Form(); $formfile = new Helper\FormFile(); $formhidden = new Helper\FormHidden(); $formsubmit = new Helper\FormSubmit(); echo $formhelper->openTag($form); echo $formhidden($progress_key); echo $formfile($file); echo $formsubmit($submit); echo $formhelper->closeTag(); ?> <iframe name="uploadTarget"></iframe> <div id="progressbar"> <div class="pg-progressbar"> <div class="pg-progress" id="pg-percent">
/** * @see Zend\Form\Element:prepare() */ public function prepare() { parent::prepare(); self::workOnElement($this->getInputfilter(), $this); }
/** * {@inheritDoc} */ public function prepare() { $this->prepareElementGroup($this, $this->extract(), $this->elementGroup); return parent::prepare(); }
public function testSettingSomeDataButNoneForCollectionReturnsSpecifiedNumberOfElementsAfterPrepare() { $form = new Form(); $form->add(new Element\Text('input')); $form->add(array('name' => 'names', 'type' => 'Collection', 'options' => array('target_element' => new Element\Text(), 'count' => 2))); $form->setData(array('input' => 'foo')); $this->assertCount(0, $form->get('names')); $form->prepare(); $this->assertCount(2, $form->get('names')); }
/** prepare **/ public function prepare() { $this->getEventManager()->trigger('pre.' . __FUNCTION__, $this, (array) $this->getformOption()); parent::prepare(); $this->getEventManager()->trigger('post.' . __FUNCTION__, $this, (array) $this->getformOption()); }
/** * @see \Zend\Form\Form::prepare() */ public function prepare() { if ($this->isPrepared) { return $this; } parent::prepare(); $this->getEventManager()->trigger(static::EVENT_PREPARE, $this); return $this; }