Skip to content

Commit

Permalink
[Form] Form::isBound() and Form::isValid() work correctly now for rea…
Browse files Browse the repository at this point in the history
…d-only forms
  • Loading branch information
webmozart committed May 18, 2011
1 parent 829aa4d commit 13a964a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Component/Form/Form.php
Expand Up @@ -452,6 +452,8 @@ public function getExtraData()
public function bind($clientData)
{
if ($this->readOnly) {
$this->bound = true;

return $this;
}

Expand Down
9 changes: 9 additions & 0 deletions tests/Symfony/Tests/Component/Form/FormTest.php
Expand Up @@ -159,6 +159,7 @@ public function testBindIsIgnoredIfReadOnly()
$form->bind('new');

$this->assertEquals('initial', $form->getData());
$this->assertTrue($form->isBound());
}

public function testNeverRequiredIfParentNotRequired()
Expand Down Expand Up @@ -297,6 +298,14 @@ public function testValidIfBound()
$this->assertTrue($this->form->isValid());
}

public function testValidIfBoundAndReadOnly()
{
$form = $this->getBuilder()->setReadOnly(true)->getForm();
$form->bind('foobar');

$this->assertTrue($form->isValid());
}

public function testNotValidIfNotBound()
{
$this->assertFalse($this->form->isValid());
Expand Down

0 comments on commit 13a964a

Please sign in to comment.