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

untick() public method

Ticks a checkbox.
public untick ( )
    public function untick()
    {
        if ('checkbox' !== $this->type) {
            throw new \LogicException(sprintf('You cannot tick "%s" as it is not a checkbox (%s).', $this->name, $this->type));
        }
        $this->setValue(false);
    }

Usage Example

Beispiel #1
0
 public function testUntick()
 {
     $node = $this->createSelectNode(array('foo' => false, 'bar' => false));
     $field = new ChoiceFormField($node);
     try {
         $field->untick();
         $this->fail('->untick() throws a \\LogicException for select boxes');
     } catch (\LogicException $e) {
         $this->assertTrue(true, '->untick() throws a \\LogicException for select boxes');
     }
     $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'checked' => 'checked'));
     $field = new ChoiceFormField($node);
     $field->untick();
     $this->assertNull($field->getValue(), '->untick() unticks checkoxes');
 }