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


PHP Form::getPhpValues方法代码示例

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


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

示例1: testgetPhpValuesWithEmptyTextarea

 public function testgetPhpValuesWithEmptyTextarea()
 {
     $dom = new \DOMDocument();
     $dom->loadHTML('
           <html>
               <form>
                   <textarea name="example"></textarea>
               </form>
           </html>
       ');
     $nodes = $dom->getElementsByTagName('form');
     $form = new Form($nodes->item(0), 'http://example.com');
     $this->assertEquals($form->getPhpValues(), array('example' => ''));
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:14,代码来源:FormTest.php

示例2: 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

示例3: submit

    /**
     * Submits a form.
     *
     * @param Form  $form   A Form instance
     * @param array $values An array of form field values
     *
     * @api
     */
    public function submit(Form $form, array $values = array())
    {
        $form->setValues($values);

        return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles());
    }
开发者ID:pmjones,项目名称:php-framework-benchmarks,代码行数:14,代码来源:Client.php

示例4: testConstructorHandlesFormAttribute

 public function testConstructorHandlesFormAttribute()
 {
     $dom = new \DOMDocument();
     $dom->loadHTML('
         <html>
             <form id="form_1" action="" method="POST">
                 <input type="checkbox" name="apples[]" value="1" checked />
                 <input form="form_2" type="checkbox" name="oranges[]" value="1" checked />
                 <input form="form_1" type="hidden" name="form_name" value="form_1" />
                 <input form="form_1" type="submit" name="button_1" value="Capture fields" />
                 <button form="form_2" type="submit" name="button_2">Submit form_2</button>
             </form>
             <input form="form_1" type="checkbox" name="apples[]" value="2" checked />
             <form id="form_2" action="" method="POST">
                 <input type="checkbox" name="oranges[]" value="2" checked />
                 <input type="checkbox" name="oranges[]" value="3" checked />
                 <input form="form_2" type="hidden" name="form_name" value="form_2" />
                 <input form="form_1" type="hidden" name="outer_field" value="success" />
                 <button form="form_1" type="submit" name="button_3">Submit from outside the form</button>
             </form>
             <button />
         </html>
     ');
     $inputElements = $dom->getElementsByTagName('input');
     $buttonElements = $dom->getElementsByTagName('button');
     // Tests if submit buttons are correctly assigned to forms
     $form1 = new Form($buttonElements->item(1), 'http://example.com');
     $this->assertSame($dom->getElementsByTagName('form')->item(0), $form1->getFormNode(), 'HTML5-compliant form attribute handled incorrectly');
     $form1 = new Form($inputElements->item(3), 'http://example.com');
     $this->assertSame($dom->getElementsByTagName('form')->item(0), $form1->getFormNode(), 'HTML5-compliant form attribute handled incorrectly');
     $form2 = new Form($buttonElements->item(0), 'http://example.com');
     $this->assertSame($dom->getElementsByTagName('form')->item(1), $form2->getFormNode(), 'HTML5-compliant form attribute handled incorrectly');
     // Tests if form elements are correctly assigned to forms
     $values1 = array('apples' => array('1', '2'), 'form_name' => 'form_1', 'button_1' => 'Capture fields', 'outer_field' => 'success');
     $values2 = array('oranges' => array('1', '2', '3'), 'form_name' => 'form_2', 'button_2' => '');
     $this->assertEquals($values1, $form1->getPhpValues(), 'HTML5-compliant form attribute handled incorrectly');
     $this->assertEquals($values2, $form2->getPhpValues(), 'HTML5-compliant form attribute handled incorrectly');
 }
开发者ID:centaurustech,项目名称:sagip,代码行数:38,代码来源:FormTest.php

示例5: testConstructorHandlesFormValues

 public function testConstructorHandlesFormValues()
 {
     $dom = $this->createTestHtml5Form();
     $inputElements = $dom->getElementsByTagName('input');
     $buttonElements = $dom->getElementsByTagName('button');
     $form1 = new Form($inputElements->item(3), 'http://example.com');
     $form2 = new Form($buttonElements->item(0), 'http://example.com');
     // Tests if form values are correctly assigned to forms
     $values1 = array('apples' => array('1', '2'), 'form_name' => 'form-1', 'button_1' => 'Capture fields', 'outer_field' => 'success');
     $values2 = array('oranges' => array('1', '2', '3'), 'form_name' => 'form_2', 'button_2' => '', 'app_frontend_form_type_contact_form_type' => array('contactType' => '', 'firstName' => 'John'));
     $this->assertEquals($values1, $form1->getPhpValues(), 'HTML5-compliant form attribute handled incorrectly');
     $this->assertEquals($values2, $form2->getPhpValues(), 'HTML5-compliant form attribute handled incorrectly');
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:13,代码来源:FormTest.php

示例6: addMenuItemForm

 /**
  * @param Form $form
  * @param $code
  * @param $elementId
  * @return Crawler
  */
 private function addMenuItemForm(Form $form, $code, $elementId)
 {
     $ajaxClient = static::createClient();
     $ajaxCrawler = $ajaxClient->request('POST', '/admin/core/append-form-field-element', array_merge($form->getPhpValues(), array('code' => $code, 'elementId' => 'page_' . $elementId, 'uniqid' => 'page')));
     foreach ($ajaxCrawler->filter('input') as $node) {
         if ($node->attributes->getNamedItem('type')) {
             if ($node->attributes->getNamedItem('type')->nodeValue == 'checkbox' || $node->attributes->getNamedItem('type')->nodeValue == 'radio') {
                 $form->set(new ChoiceFormField($node));
                 continue;
             }
             if ($node->attributes->getNamedItem('type') == 'file') {
                 $form->set(new FileFormField($node));
                 continue;
             }
         }
         $form->set(new InputFormField($node));
     }
     foreach ($ajaxCrawler->filter('select') as $node) {
         $form->set(new ChoiceFormField($node));
     }
     foreach ($ajaxCrawler->filter('textarea') as $node) {
         $form->set(new TextareaFormField($node));
     }
     return $ajaxCrawler;
 }
开发者ID:kea,项目名称:PUGXCmfPageBundle,代码行数:31,代码来源:PageAdminTest.php

示例7: makeRequestUsingForm

 /**
  * Make a request to a URL using form parameters.
  *
  * @param  Form $form
  * @return static
  */
 protected function makeRequestUsingForm(Form $form)
 {
     return $this->makeRequest($form->getMethod(), $form->getUri(), $form->getPhpValues(), [], $form->getFiles());
 }
开发者ID:kmhrussell,项目名称:Integrated,代码行数:10,代码来源:LaravelTestCase.php

示例8: submit

 /**
  * Submit a form
  *
  * @param \Symfony\Component\DomCrawler\Form $form
  * @return \TYPO3\Flow\Http\Response
  * @api
  */
 public function submit(Form $form)
 {
     return $this->request($form->getUri(), $form->getMethod(), $form->getPhpValues(), $form->getPhpFiles());
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:11,代码来源:Browser.php

示例9: submitForm

 /**
  * 
  * @param \Symfony\Component\DomCrawler\Form $form
  * @param string    $method     The Request Method
  */
 public function submitForm(Form $form, $method = "POST")
 {
     $this->getClient()->request($method, $form->getUri(), $form->getPhpValues());
 }
开发者ID:doyolabs,项目名称:symfony-test,代码行数:9,代码来源:WebTestCase.php

示例10: disableModuleAsync

 /**
  * @param Form    $form
  * @param string  $package
  * @param string  $slug
  * @param Session $session
  *
  * @return Promise
  *
  * @rejects RequestException
  */
 public function disableModuleAsync(Form $form, $package, $slug, Session $session)
 {
     $formData = $form->getPhpValues();
     if (empty($formData['modules'][$package][$slug]['enable'])) {
         // The module is already disabled.
         return new FulfilledPromise(null);
     }
     unset($formData['modules'][$package][$slug]['enable']);
     return $this->client->requestAsync($form->getMethod(), $form->getUri(), [RequestOptions::COOKIES => $session->getCookieJar(), RequestOptions::AUTH => $session->getAuthData(), RequestOptions::FORM_PARAMS => $formData, RequestOptions::HEADERS => ['referer' => $form->getUri()], RequestOptions::ALLOW_REDIRECTS => false])->then(function () {
         // Resolve to null.
     });
 }
开发者ID:Briareos,项目名称:Undine,代码行数:22,代码来源:Client.php


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