当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::has方法代码示例

本文整理汇总了PHP中Zend\Form\Form::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::has方法的具体用法?PHP Form::has怎么用?PHP Form::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Form\Form的用法示例。


在下文中一共展示了Form::has方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getForm

 /**
  * {@inheritDoc}
  */
 public function getForm()
 {
     $currentStep = $this->getCurrentStep();
     if (!$currentStep) {
         return;
     }
     if (null === $this->form) {
         $this->form = $this->formFactory->create();
         $this->form->setAttribute('action', sprintf('?%s=%s', $this->getOptions()->getTokenParamName(), $this->getUniqueId()));
         if (!$this->getSteps()->getPrevious($currentStep)) {
             $this->form->remove('previous');
         }
         if (!$this->getSteps()->getNext($currentStep)) {
             $this->form->remove('next');
         } else {
             $this->form->remove('valid');
         }
     }
     $stepForm = $currentStep->getForm();
     if ($stepForm instanceof Form) {
         if ($this->form->has(self::STEP_FORM_NAME)) {
             $this->form->remove(self::STEP_FORM_NAME);
         }
         $stepForm->setName(self::STEP_FORM_NAME);
         $stepForm->populateValues($currentStep->getData());
         $this->form->add($stepForm);
     }
     return $this->form;
 }
开发者ID:Tribalx,项目名称:Wizard,代码行数:32,代码来源:Wizard.php

示例2: testCanAddFieldsetsUsingSpecs

 public function testCanAddFieldsetsUsingSpecs()
 {
     $this->form->add(array('type' => 'Zend\\Form\\Fieldset', 'name' => 'foo', 'attributes' => array('type' => 'fieldset', 'class' => 'foo-class', 'data-js-type' => 'my.form.fieldset')));
     $this->assertTrue($this->form->has('foo'));
     $fieldset = $this->form->get('foo');
     $this->assertInstanceOf('Zend\\Form\\FieldsetInterface', $fieldset);
     $this->assertEquals('foo', $fieldset->getName());
     $this->assertEquals('fieldset', $fieldset->getAttribute('type'));
     $this->assertEquals('foo-class', $fieldset->getAttribute('class'));
     $this->assertEquals('my.form.fieldset', $fieldset->getAttribute('data-js-type'));
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:11,代码来源:FormTest.php

示例3: testAddRemove

 public function testAddRemove()
 {
     $form = clone $this->form;
     $this->assertEquals($form, $this->form);
     $file = new Element\File('file_resource');
     $this->form->add($file);
     $this->assertTrue($this->form->has('file_resource'));
     $this->assertNotEquals($form, $this->form);
     $this->form->remove('file_resource');
     $this->assertEquals($form, $this->form);
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:11,代码来源:FormTest.php

示例4: __invoke

 /**
  * @param Form $form
  * @param array $fields
  * @param array $overwrite
  *
  * @return string
  */
 public function __invoke($form, $fields, $overwrite = null)
 {
     if ($overwrite === null) {
         $overwrite = array();
     }
     if (!is_array($fields)) {
         $fields = array($fields);
     }
     $html = '';
     foreach ($fields as $i => $field) {
         $addon = '';
         if (!is_int($i)) {
             $addon = $field;
             $field = $i;
         }
         if (!$form->has($field)) {
             throw new \Exception(sprintf('Element doesn\'t exists \'%s\'', $field));
         }
         $element = $form->get($field);
         $type = strtolower($element->getAttribute('type'));
         if (array_key_exists($field, $overwrite)) {
             if ($type === 'submit') {
                 $element->setValue($overwrite[$field]);
             } else {
                 $element->setOption('label', $overwrite[$field]);
             }
         }
         $plugin = $this->getPlugin($type);
         $prefix = '';
         $encaps = '%s';
         switch ($type) {
             case 'checkbox':
                 $encaps = sprintf("<div class=\"checkbox-block\">%s</div><div class=\"col-xs-10\">%s</div>", '%s', $this->getLabel($element));
                 break;
             case "textarea":
                 if (preg_match('/readonly/i', $element->getAttribute('class'))) {
                     $prefix = '<p class="toggle-edit"><a href="#">Edit</a></p><iframe style="width:200px; height:100px; display: none;"></iframe>';
                 }
             default:
                 $prefix .= $this->getLabel($element);
                 break;
         }
         $input = $plugin($element);
         if (!empty($prefix)) {
             $prefix = sprintf($this->labelBlock, $prefix);
         }
         $html .= sprintf($this->format, $element->getName(), $prefix, sprintf($encaps, $input), $addon, $this->buildErrorMessage($element));
     }
     return $html;
 }
开发者ID:elmosgot,项目名称:cool-builder,代码行数:57,代码来源:RenderElements.php

示例5: remove

 /**
  * {@inheritDoc}
  */
 public function remove($elementOrFieldset)
 {
     if (!parent::has($elementOrFieldset)) {
         if ($elementOrFieldset === 'captcha') {
             $elementOrFieldset = $this->getCaptchaElementName();
         } elseif ($elementOrFieldset === 'csrf') {
             $elementOrFieldset = $this->getCsrfElementName();
         }
     }
     return parent::remove($elementOrFieldset);
 }
开发者ID:coolms,项目名称:common,代码行数:14,代码来源:Form.php


注:本文中的Zend\Form\Form::has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。