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


PHP Form::all方法代码示例

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


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

示例1: testConstructorLoadsOnlyFieldsOfTheRightForm

 public function testConstructorLoadsOnlyFieldsOfTheRightForm()
 {
     $dom = $this->createTestMultipleForm();
     $nodes = $dom->getElementsByTagName('form');
     $buttonElements = $dom->getElementsByTagName('button');
     $form = new Form($nodes->item(0), 'http://example.com');
     $this->assertCount(3, $form->all());
     $form = new Form($buttonElements->item(1), 'http://example.com');
     $this->assertCount(5, $form->all());
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:10,代码来源:FormTest.php

示例2: getFormValuesFor

 /**
  * Returns an array of name => value pairs for the passed form.
  *
  * For form fields containing a name ending in [], an array is
  * created out of all field values with the given name.
  *
  * @param \Symfony\Component\DomCrawler\Form the form
  * @return array an array of name => value pairs
  */
 protected function getFormValuesFor(Form $form)
 {
     $values = [];
     $fields = $form->all();
     foreach ($fields as $field) {
         if ($field->isDisabled() || !$field->hasValue() || $field instanceof FileFormField) {
             continue;
         }
         $fieldName = $this->getSubmissionFormFieldName($field->getName());
         if (substr($field->getName(), -2) === '[]') {
             if (!isset($values[$fieldName])) {
                 $values[$fieldName] = [];
             }
             $values[$fieldName][] = $field->getValue();
         } else {
             $values[$fieldName] = $field->getValue();
         }
     }
     return $values;
 }
开发者ID:vladislavl-hyuna,项目名称:crmapp,代码行数:29,代码来源:InnerBrowser.php

示例3: mergeForms

 /**
  * Merges second form values into first one.
  *
  * @param Form $to   merging target
  * @param Form $from merging source
  */
 private function mergeForms(Form $to, Form $from)
 {
     foreach ($from->all() as $name => $field) {
         $fieldReflection = new \ReflectionObject($field);
         $nodeReflection = $fieldReflection->getProperty('node');
         $valueReflection = $fieldReflection->getProperty('value');
         $nodeReflection->setAccessible(true);
         $valueReflection->setAccessible(true);
         $isIgnoredField = $field instanceof InputFormField && in_array($nodeReflection->getValue($field)->getAttribute('type'), array('submit', 'button', 'image'), true);
         if (!$isIgnoredField) {
             $valueReflection->setValue($to[$name], $valueReflection->getValue($field));
         }
     }
 }
开发者ID:penguinclub,项目名称:penguinweb_drupal8,代码行数:20,代码来源:BrowserKitDriver.php

示例4: getFormValuesFor

 /**
  * Returns an array of name => value pairs for the passed form.
  *
  * The function calls getPhpValues on the passed form object, then
  * resets numeric array indexes for array field names without array
  * keys specified (i.e. 'fieldname[]' but not 'fieldname[keyname]')
  * as expected by setCheckboxBoolValues.
  *
  * @param \Symfony\Component\DomCrawler\Form the form
  * @return array an array of name => value pairs
  */
 protected function getFormValuesFor(Form $form)
 {
     $values = $form->getPhpValues();
     $fields = $form->all();
     foreach ($fields as $field) {
         $name = $this->getSubmissionFormFieldName($field->getName());
         if (!empty($values[$name]) && substr($field->getName(), -2) === '[]') {
             $values[$name] = array_values($values[$name]);
         }
     }
     return $values;
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:23,代码来源:InnerBrowser.php

示例5: submitEditForm

 /**
  * Edits the data of a form
  *
  * @param  Client $client
  * @param  Form   $form
  * @param  array  $data
  */
 protected function submitEditForm(Client $client, Form $form, array $data = array())
 {
     $originalData = array();
     foreach ($form->all() as $fieldName => $formField) {
         $originalData[$fieldName] = $formField->getValue();
     }
     $data = array_merge($originalData, $data);
     $this->submitForm($client, $form, $data);
 }
开发者ID:biggtfish,项目名称:forkcms,代码行数:16,代码来源:WebTestCase.php


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