Prechádzať zdrojové kódy

[Form][FrameworkBundle][TwigBundle] Renamed view variable 'disabled' to 'read_only' to match with the according FormInterface methods

Bernhard Schussek 14 rokov pred
rodič
commit
37e8e1270c

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/checkbox_widget.html.php

@@ -2,7 +2,7 @@
     id="<?php echo $id; ?>"
     name="<?php echo $name ?>"
     <?php if ($value): ?>value="<?php echo $value ?>"<?php endif ?>
-    <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+    <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
     <?php if ($required): ?>required="required"<?php endif ?>
     <?php if ($checked): ?>checked="checked"<?php endif ?>
     <?php if (isset($attr)): echo $renderer->getTheme()->attributes($attr); endif; ?>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget.html.php

@@ -7,7 +7,7 @@
     <select
         id="<?php echo $id ?>"
         name="<?php echo $name ?>"
-        <?php if ($disabled): ?> disabled="disabled"<?php endif ?>
+        <?php if ($read_only): ?> disabled="disabled"<?php endif ?>
         <?php if ($multiple): ?> multiple="multiple"<?php endif ?>
         <?php if ($class): ?> class="<?php echo $class ?>"<?php endif ?>
         <?php if (isset($attr)): echo $renderer->getTheme()->attributes($attr); endif; ?>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/date_widget.html.php

@@ -3,7 +3,7 @@
         id="<?php echo $id ?>"
         name="<?php echo $name ?>"
         value="<?php echo $value ?>"
-        <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+        <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
         <?php if ($required): ?>required="required"<?php endif ?>
         <?php if ($class): ?>class="<?php echo $class ?>"<?php endif ?>
         <?php if (isset($attr)): echo $renderer->getTheme()->attributes($attr); endif; ?>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/field_widget.html.php

@@ -2,7 +2,7 @@
     name="<?php echo $name ?>"
     value="<?php echo $value ?>"
     <?php if ($class): ?>class="<?php echo $class; ?>"<?php endif; ?>
-    <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+    <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
     <?php if ($required): ?>required="required"<?php endif ?>
     <?php if ($max_length && $max_length > 0): ?>maxlength="<?php echo $max_length ?>"<?php endif; ?>
     <?php if ($size && $size > 0): ?>size="<?php echo $size ?>"<?php endif; ?>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/hidden_widget.html.php

@@ -2,6 +2,6 @@
     id="<?php echo $id ?>"
     name="<?php echo $name ?>"
     value="<?php echo $value ?>"
-    <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+    <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
     <?php if (isset($attr)): echo $renderer->getTheme()->attributes($attr); endif; ?>
 />

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/number_widget.html.php

@@ -2,7 +2,7 @@
     id="<?php echo $id ?>"
     name="<?php echo $name ?>"
     value="<?php echo $value ?>"
-    <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+    <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
     <?php if ($required): ?>required="required"<?php endif ?>
     <?php if ($class): ?>class="<?php echo $class ?>"<?php endif ?>
     <?php if ($max_length && $max_length > 0): ?>maxlength="<?php echo $max_length; ?>"<?php endif; ?>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/password_widget.html.php

@@ -2,7 +2,7 @@
     id="<?php echo $id ?>"
     name="<?php echo $name ?>"
     value="<?php echo $value ?>"
-    <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+    <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
     <?php if ($required): ?>required="required"<?php endif ?>
     <?php if ($class): ?>class="<?php echo $class ?>"<?php endif ?>
     <?php if ($max_length && $max_length > 0): ?>maxlength="<?php echo $max_length; ?>"<?php endif; ?>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/radio_widget.html.php

@@ -2,7 +2,7 @@
     id="<?php echo $id ?>"
     name="<?php echo $name ?>"
     value="<?php echo $value ?>"
-    <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+    <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
     <?php if ($required): ?>required="required"<?php endif ?>
     <?php if ($checked): ?>checked="checked"<?php endif ?>
     <?php if ($class): ?>class="<?php echo $class ?>"<?php endif ?>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/text_widget.html.php

@@ -3,7 +3,7 @@
     name="<?php echo $name ?>"
     value="<?php echo $value ?>"
     <?php if ($class): ?>class="<?php echo $class; ?>"<?php endif; ?>
-    <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+    <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
     <?php if ($required): ?>required="required"<?php endif ?>
     <?php if ($max_length && $max_length > 0): ?>maxlength="<?php echo $max_length; ?>"<?php endif; ?>
     <?php if ($size && $size > 0): ?>size="<?php echo $size; ?>"<?php endif; ?>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/textarea_widget.html.php

@@ -1,7 +1,7 @@
 <textarea
     id="<?php echo $id ?>"
     name="<?php echo $name ?>"
-    <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+    <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
     <?php if ($required): ?>required="required"<?php endif ?>
     <?php if ($class): ?>class="<?php echo $class ?>"<?php endif ?>
     <?php if (isset($attr)): echo $renderer->getTheme()->attributes($attr); endif; ?>

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/url_widget.html.php

@@ -2,7 +2,7 @@
     id="<?php echo $id ?>"
     name="<?php echo $name ?>"
     value="<?php echo $value ?>"
-    <?php if ($disabled): ?>disabled="disabled"<?php endif ?>
+    <?php if ($read_only): ?>disabled="disabled"<?php endif ?>
     <?php if ($required): ?>required="required"<?php endif ?>
     <?php if ($class): ?>class="<?php echo $class ?>"<?php endif ?>
     <?php if (isset($attr)): echo $renderer->getTheme()->attributes($attr); endif; ?>

+ 1 - 1
src/Symfony/Bundle/TwigBundle/Resources/views/widgets.html.twig

@@ -43,7 +43,7 @@
 
 {% block attributes %}
 {% spaceless %}
-    id="{{ id }}" name="{{ name }}"{% if class %} class="{{ class }}"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if size %} size="{{ size }}"{% endif %}
+    id="{{ id }}" name="{{ name }}"{% if class %} class="{{ class }}"{% endif %}{% if read_only %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if size %} size="{{ size }}"{% endif %}
     {% for attrname,attrvalue in attr %}{{attrname}}="{{attrvalue}}" {% endfor %}
 {% endspaceless %}
 {% endblock attributes %}

+ 2 - 2
src/Symfony/Component/Form/Renderer/Theme/PhpTheme.php

@@ -252,7 +252,7 @@ class PhpTheme implements ThemeInterface
     {
         $html = '<textarea id="' . $this->escape($attr['id']) . "' " .
                 'name="' . $this->escape($attr['name']) . "' ";
-        if ($attr['disabled']) {
+        if ($attr['read_only']) {
             $html .= 'disabled="disabled" ';
         }
         if ($attr['required']) {
@@ -292,7 +292,7 @@ class PhpTheme implements ThemeInterface
         if ($attr['value']) {
             $html .= 'value="' . $this->escape($attr['value']) .'" ';
         }
-        if ($attr['disabled']) {
+        if ($attr['read_only']) {
             $html .= 'disabled="disabled" ';
         }
         if ($attr['required']) {

+ 1 - 1
src/Symfony/Component/Form/Type/FieldType.php

@@ -80,7 +80,7 @@ class FieldType extends AbstractType
         $renderer->setVar('name', $name);
         $renderer->setVar('errors', $form->getErrors());
         $renderer->setVar('value', $form->getClientData());
-        $renderer->setVar('disabled', $form->isReadOnly());
+        $renderer->setVar('read_only', $form->isReadOnly());
         $renderer->setVar('required', $form->isRequired());
         $renderer->setVar('class', null);
         $renderer->setVar('max_length', null);

+ 4 - 4
tests/Symfony/Tests/Component/Form/Renderer/Theme/AbstractThemeTest.php

@@ -34,7 +34,7 @@ abstract class AbstractThemeTest extends \PHPUnit_Framework_TestCase
             'value' => '',
             'class' => '',
             'max_length' => null,
-            'disabled' => false,
+            'read_only' => false,
             'required' => false,
             'size' => null
         ));
@@ -47,7 +47,7 @@ abstract class AbstractThemeTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($input->hasAttribute('class'), "No class attribute by default.");
         $this->assertFalse($input->hasAttribute('maxlength'), "has no maxlength attribute.");
         $this->assertFalse($input->hasAttribute('size'), "has no size attribute");
-        $this->assertFalse($input->hasAttribute('disabled'));
+        $this->assertFalse($input->hasAttribute('read_only'));
         $this->assertFalse($input->hasAttribute('required'));
     }
 
@@ -59,7 +59,7 @@ abstract class AbstractThemeTest extends \PHPUnit_Framework_TestCase
             'value' => 'test',
             'class' => 'foo',
             'max_length' => 128,
-            'disabled' => true,
+            'read_only' => true,
             'required' => true,
             'size' => 20,
             'attr' => array('accesskey' => 'G', 'title' => 'Foo'),
@@ -91,7 +91,7 @@ abstract class AbstractThemeTest extends \PHPUnit_Framework_TestCase
             'name' => 'foo',
             'value' => 'foo',
             'class' => 'foo',
-            'disabled' => false,
+            'read_only' => false,
             'required' => false,
             'empty_value' => '---',
             'expanded' => false,