本文整理汇总了PHP中Zend\Form\Form::prepare方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::prepare方法的具体用法?PHP Form::prepare怎么用?PHP Form::prepare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Form
的用法示例。
在下文中一共展示了Form::prepare方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
/**
* 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();
}
示例2: __invoke
/**
* 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;
}
示例3: __invoke
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;
}
示例4: testResetPasswordValueIfFormIsNotValid
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());
}
示例5: prepare
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();
}
示例6: __invoke
/**
* @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;
}
示例7: __invoke
/**
* 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;
}
示例8: prepare
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();
}
示例9: prepare
public function prepare()
{
parent::prepare();
return $this;
}
示例10: Form
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">
示例11: prepare
/**
* @see Zend\Form\Element:prepare()
*/
public function prepare()
{
parent::prepare();
self::workOnElement($this->getInputfilter(), $this);
}
示例12: prepare
/**
* {@inheritDoc}
*/
public function prepare()
{
$this->prepareElementGroup($this, $this->extract(), $this->elementGroup);
return parent::prepare();
}
示例13: testSettingSomeDataButNoneForCollectionReturnsSpecifiedNumberOfElementsAfterPrepare
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'));
}
示例14: prepare
/** prepare **/
public function prepare()
{
$this->getEventManager()->trigger('pre.' . __FUNCTION__, $this, (array) $this->getformOption());
parent::prepare();
$this->getEventManager()->trigger('post.' . __FUNCTION__, $this, (array) $this->getformOption());
}
示例15: prepare
/**
* @see \Zend\Form\Form::prepare()
*/
public function prepare()
{
if ($this->isPrepared) {
return $this;
}
parent::prepare();
$this->getEventManager()->trigger(static::EVENT_PREPARE, $this);
return $this;
}