Symfony\Component\DomCrawler\Field\ChoiceFormField::disableValidation PHP Method

disableValidation() public method

Disables the internal validation of the field.
public disableValidation ( ) : self
return self
    public function disableValidation()
    {
        $this->validationDisabled = true;
        return $this;
    }

Usage Example

 public function testDisableValidation()
 {
     $node = $this->createSelectNode(array('foo' => false, 'bar' => false));
     $field = new ChoiceFormField($node);
     $field->disableValidation();
     $field->setValue('foobar');
     $this->assertEquals('foobar', $field->getValue(), '->disableValidation() allows to set a value which is not in the selected options.');
     $node = $this->createSelectNode(array('foo' => false, 'bar' => false), array('multiple' => 'multiple'));
     $field = new ChoiceFormField($node);
     $field->disableValidation();
     $field->setValue(array('foobar'));
     $this->assertEquals(array('foobar'), $field->getValue(), '->disableValidation() allows to set a value which is not in the selected options.');
 }