select() public method

Sets the value of the field.
public select ( string $value )
$value string The value of the field
コード例 #1
0
 public function testOptionWithNoValue()
 {
     $node = $this->createSelectNodeWithEmptyOption(array('foo' => false, 'bar' => false));
     $field = new ChoiceFormField($node);
     $field->select('foo');
     $this->assertEquals('foo', $field->getValue(), '->select() changes the selected option');
 }
コード例 #2
0
 public function testSelect()
 {
     $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'checked' => 'checked'));
     $field = new ChoiceFormField($node);
     $field->select(true);
     $this->assertEquals(1, $field->getValue(), '->select() changes the value of the field');
     $field->select(false);
     $this->assertEquals(null, $field->getValue(), '->select() changes the value of the field');
     $node = $this->createSelectNode(array('foo' => false, 'bar' => false));
     $field = new ChoiceFormField($node);
     $field->select('foo');
     $this->assertEquals('foo', $field->getValue(), '->select() changes the selected option');
 }