get() public method

Gets a named field.
public get ( string $name ) : FormField
$name string The field name
return Symfony\Component\DomCrawler\Field\FormField The field instance
Ejemplo n.º 1
0
 /**
  * @param integer $value
  * @return $this
  */
 protected function setStatus($value)
 {
     $status = $this->form->get('field_issue_status[und]');
     $status->setValue($value);
     $this->form->set($status);
     return $this;
 }
Ejemplo n.º 2
0
 public function testDifferentFieldTypesWithSameName()
 {
     $dom = new \DOMDocument();
     $dom->loadHTML('
         <html>
             <body>
                 <form action="/">
                     <input type="hidden" name="option" value="default">
                     <input type="radio" name="option" value="A">
                     <input type="radio" name="option" value="B">
                     <input type="hidden" name="settings[1]" value="0">
                     <input type="checkbox" name="settings[1]" value="1" id="setting-1">
                     <button>klickme</button>
                 </form>
             </body>
         </html>
     ');
     $form = new Form($dom->getElementsByTagName('form')->item(0), 'http://example.com');
     $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Field\\ChoiceFormField', $form->get('option'));
 }
Ejemplo n.º 3
0
 /**
  * Returns an array of values for the field with the passed name.  Usually
  * the array consists of a single value.  Used by proceedSeeInField
  *
  * @param Form $form
  * @param string $fieldName
  * @return array
  */
 private function getFormFieldValues(Form $form, $fieldName)
 {
     $strField = $this->getSubmissionFormFieldName($fieldName);
     $values = [];
     if ($form->has($strField)) {
         $fields = $form->get($strField);
         // $form->get returns an array for fields with names ending in []
         if (!is_array($fields)) {
             $fields = [$fields];
         }
         foreach ($fields as $field) {
             if (!$field->hasValue()) {
                 continue;
             }
             // $field->getValue may return an array (multi-select for example) or a string value
             $values = array_merge($values, (array) $field->getValue());
         }
     }
     return $values;
 }
 /**
  * @param Form $form
  * @param Quote $quote
  * @param int $customQuantity
  * @return array
  */
 protected function setFormData(Form $form, Quote $quote, $customQuantity)
 {
     $selectedOffers = [];
     foreach ($quote->getQuoteProducts() as $quoteProduct) {
         /** @var \OroB2B\Bundle\SaleBundle\Entity\QuoteProductOffer $quoteProductOffer */
         $quoteProductOffer = $quoteProduct->getQuoteProductOffers()->first();
         foreach ($form->get('orob2b_sale_quote_to_order') as $key => $row) {
             if (!is_array($row)) {
                 continue;
             }
             /** @var ChoiceFormField $offer */
             $offer = $form->get('offer_choice_' . $key);
             if ((int) $offer->getValue() !== (int) $quoteProductOffer->getId()) {
                 continue;
             }
             if ($quoteProductOffer->isAllowIncrements()) {
                 $form['orob2b_sale_quote_to_order[' . $key . '][quantity]'] = $customQuantity;
             } else {
                 $form['orob2b_sale_quote_to_order[' . $key . '][quantity]'] = $quoteProductOffer->getQuantity();
             }
             $selectedOffers[] = $quoteProductOffer;
         }
     }
     return $selectedOffers;
 }