Example #1
0
 /**
  * @param array $completions
  * @param array $uninputs
  * @return $this
  * @throws ErrorException
  * @throws NoLocationException
  * @throws StateException
  * @throws \Exception
  */
 public function submit(array $completions, array $uninputs = [])
 {
     $this->form->setSimpleXMLForm($this->_source)->addCompletions($completions);
     foreach ($uninputs as $uninput) {
         $this->form->removeInput($uninput);
     }
     $method = 'get';
     $action = $this->crawler->getUrl();
     if ($this->form->hasAttribute('method')) {
         $method = $this->form->getAttribute('method');
     }
     if ($this->form->hasAttribute('action')) {
         $action = $this->form->getAttribute('action');
         if (isset($action[0])) {
             if ('/' === $action[0]) {
                 $action = $this->crawler->getBaseUrl() . $action;
             } else {
                 throw new \Exception("TODO: " . __FILE__ . " L" . __LINE__);
             }
         }
     }
     $this->crawler->submit($method, $action, $this->form->getData());
     return $this;
 }