Przeglądaj źródła

ZF-7660: always specify required flag on Dijits

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20621 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 lat temu
rodzic
commit
6cab8781b0

+ 1 - 3
library/Zend/Dojo/Form/Decorator/DijitElement.php

@@ -164,9 +164,7 @@ class Zend_Dojo_Form_Decorator_DijitElement extends Zend_Form_Decorator_ViewHelp
         $name      = $element->getFullyQualifiedName();
 
         $dijitParams = $this->getDijitParams();
-        if ($element->isRequired()) {
-            $dijitParams['required'] = true;
-        }
+        $dijitParams['required'] = $element->isRequired();
 
         $id = $element->getId();
         if ($view->dojo()->hasDijit($id)) {

+ 1 - 1
tests/Zend/Dojo/Form/AllTests.php

@@ -20,7 +20,7 @@
  * @version    $Id$
  */
 
-require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
+require_once dirname(__FILE__) . '/../../../TestHelper.php';
 
 if (!defined('PHPUnit_MAIN_METHOD')) {
     define('PHPUnit_MAIN_METHOD', 'Zend_Dojo_Form_AllTests::main');

+ 10 - 0
tests/Zend/Dojo/Form/Decorator/DijitElementTest.php

@@ -213,6 +213,16 @@ class Zend_Dojo_Form_Decorator_DijitElementTest extends PHPUnit_Framework_TestCa
         $html = $this->decorator->render('');
         $this->assertContains('required="', $html);
     }
+
+    /**
+     * @group ZF-7660
+     */
+    public function testRenderingShouldRenderRequiredFlagAlways()
+    {
+        $this->element->setRequired(false);
+        $html = $this->decorator->render('');
+        $this->assertContains('required="false"', $html, $html);
+    }
 }
 
 // Call Zend_Dojo_Form_Decorator_DijitElementTest::main() if this source file is executed directly.