Symfony\Component\DomCrawler\Form::has PHP Method

has() public method

Returns true if the named field exists.
public has ( string $name ) : boolean
$name string The field name
return boolean true if the field exists, false otherwise
    public function has($name)
    {
        return $this->fields->has($name);
    }

Usage Example

 public function isValid(Form $form)
 {
     if ($form->has('token')) {
         $values = $form->getValues();
         $values['token'] = 'modified by csrf scanner';
         $form->setValues($values);
         $this->client->submit($form);
         $status = $this->client->getResponse()->getStatus();
         if (403 == $status) {
             return true;
         }
         $this->message = "403 response expected, but got a {$status}";
     } else {
         $this->message = "No 'token' input field found";
     }
     return false;
 }
All Usage Examples Of Symfony\Component\DomCrawler\Form::has