From 1532b8bc865923b93dd38e643fe57e164d5d0272 Mon Sep 17 00:00:00 2001 From: Bart van den Burg Date: Wed, 21 Dec 2011 12:01:58 +0100 Subject: [PATCH] added a setReadOnly method --- src/Symfony/Component/Form/Form.php | 14 ++++++++++++++ tests/Symfony/Tests/Component/Form/FormTest.php | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 0b9cdcf1bb76..59638e3300be 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -294,6 +294,20 @@ public function isReadOnly() return true; } + /** + * Sets whether this form is read only. + * + * @param Boolean + * + * @return Form The current form + */ + public function setReadOnly($readOnly) + { + $this->readOnly = (Boolean) $readOnly; + + return $this; + } + /** * Sets the parent form. * diff --git a/tests/Symfony/Tests/Component/Form/FormTest.php b/tests/Symfony/Tests/Component/Form/FormTest.php index 4fbf6ff9b7b9..4f901d933dfc 100644 --- a/tests/Symfony/Tests/Component/Form/FormTest.php +++ b/tests/Symfony/Tests/Component/Form/FormTest.php @@ -229,6 +229,18 @@ public function testNotReadOnly() $this->assertFalse($child->isReadOnly()); } + public function testSetReadOnly() + { + $form = $this->getBuilder()->getForm(); + $this->assertFalse($form->isReadOnly()); + + $form->setReadOnly(true); + $this->assertTrue($form->isReadOnly()); + + $form->setReadOnly(false); + $this->assertFalse($form->isReadOnly()); + } + public function testCloneChildren() { $child = $this->getBuilder('child')->getForm();