當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。