當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Form::getFormNode方法代碼示例

本文整理匯總了PHP中Symfony\Component\DomCrawler\Form::getFormNode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::getFormNode方法的具體用法?PHP Form::getFormNode怎麽用?PHP Form::getFormNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DomCrawler\Form的用法示例。


在下文中一共展示了Form::getFormNode方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetFormNode

 public function testGetFormNode()
 {
     $dom = new \DOMDocument();
     $dom->loadHTML('<html><form><input type="submit" /></form></html>');
     $form = new Form($dom->getElementsByTagName('input')->item(0));
     $this->assertSame($dom->getElementsByTagName('form')->item(0), $form->getFormNode(), '->getFormNode() returns the form node associated with this form');
 }
開發者ID:hellovic,項目名稱:symfony,代碼行數:7,代碼來源:FormTest.php

示例2: createFromForm

 /**
  * @param Form $form
  *
  * @return ModuleList
  */
 public static function createFromForm(Form $form)
 {
     $node = new Crawler($form->getFormNode());
     // Example: <input type="checkbox" id="edit-modules-other-oxygen-enable" name="modules[Other][oxygen][enable]" value="1" class="form-checkbox" />
     $inputs = $node->filter('input[type="checkbox"][id^="edit-modules-"]');
     $modules = [];
     foreach ($inputs as $input) {
         /** @var \DOMElement $input */
         if (!$input->hasAttribute('name')) {
             continue;
         }
         $enabled = $input->hasAttribute('checked');
         $match = preg_match('{^modules\\[([^\\]]+)\\]\\[([^\\]]+)\\]\\[enable\\]$}', $input->getAttribute('name'), $matches);
         if (!$match) {
             continue;
         }
         list(, $package, $slug) = $matches;
         $modules[] = new ModuleListItem($package, $slug, $enabled);
     }
     return new self($modules);
 }
開發者ID:Briareos,項目名稱:Undine,代碼行數:26,代碼來源:ModuleList.php

示例3: submitForm

 /**
  * @param Form $form
  *
  * @return Crawler
  */
 protected function submitForm(Form $form)
 {
     $action = $form->getFormNode()->getAttribute('data-action');
     $form->getFormNode()->setAttribute('action', $action);
     return $this->client->submit($form);
 }
開發者ID:open-orchestra,項目名稱:open-orchestra,代碼行數:11,代碼來源:AbstractFormTest.php

示例4: testSubmitWithoutAFormButton

 public function testSubmitWithoutAFormButton()
 {
     $dom = new \DOMDocument();
     $dom->loadHTML('
         <html>
             <form>
                 <input type="foo" />
             </form>
         </html>
     ');
     $nodes = $dom->getElementsByTagName('form');
     $form = new Form($nodes->item(0), 'http://example.com');
     $this->assertSame($nodes->item(0), $form->getFormNode(), '->getFormNode() returns the form node associated with this form');
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:14,代碼來源:FormTest.php

示例5: submit

 private function submit(Form $form)
 {
     $formId = $this->getFormNodeId($form->getFormNode());
     if (isset($this->forms[$formId])) {
         $this->mergeForms($form, $this->forms[$formId]);
     }
     // remove empty file fields from request
     foreach ($form->getFiles() as $name => $field) {
         if (empty($field['name']) && empty($field['tmp_name'])) {
             $form->remove($name);
         }
     }
     foreach ($form->all() as $field) {
         // Add a fix for https://github.com/symfony/symfony/pull/10733 to support Symfony versions which are not fixed
         if ($field instanceof TextareaFormField && null === $field->getValue()) {
             $field->setValue('');
         }
     }
     $this->client->submit($form);
     $this->forms = array();
 }
開發者ID:penguinclub,項目名稱:penguinweb_drupal8,代碼行數:21,代碼來源:BrowserKitDriver.php


注:本文中的Symfony\Component\DomCrawler\Form::getFormNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。