Explorar o código

[FrameworkBundle] Attributes can now be passed when rendering form fields with the PHP renderer

Bernhard Schussek %!s(int64=14) %!d(string=hai) anos
pai
achega
114b2cf6c1

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/checkbox_field.php

@@ -4,4 +4,5 @@
     <?php if ($field->hasValue()): ?>value="<?php echo $field->getValue() ?>"<?php endif ?>
     <?php if ($field->isDisabled()): ?>disabled="disabled"<?php endif ?>
     <?php if ($field->isChecked()): ?>checked="checked"<?php endif ?>
+    <?php echo $view['form']->attributes($attr) ?>
 />

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_field.php

@@ -9,6 +9,7 @@
         name="<?php echo $field->getName() ?>"
         <?php if ($field->isDisabled()): ?> disabled="disabled"<?php endif ?>
         <?php if ($field->isMultipleChoice()): ?> multiple="multiple"<?php endif ?>
+        <?php echo $view['form']->attributes($attr) ?>
     >
         <?php if (count($field->getPreferredChoices()) > 0): ?>
             <?php foreach ($field->getPreferredChoices() as $choice => $label): ?>

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/date_field.php

@@ -4,6 +4,7 @@
         name="<?php echo $field->getName() ?>"
         value="<?php echo $field->getDisplayedData() ?>"
         <?php if ($field->isDisabled()): ?>disabled="disabled"<?php endif ?>
+        <?php echo $view['form']->attributes($attr) ?>
     />
 <?php else: ?>
     <?php echo str_replace(array('{{ year }}', '{{ month }}', '{{ day }}'), array(

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/file_field.php

@@ -2,6 +2,7 @@
     id="<?php echo $field['file']->getId() ?>"
     name="<?php echo $field['file']->getName() ?>"
     <?php if ($field['file']->isDisabled()): ?>disabled="disabled"<?php endif ?>
+    <?php echo $view['form']->attributes($attr) ?>
 />
 
 <?php echo $view['form']->render($field['token']) ?>

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/hidden_field.php

@@ -3,4 +3,5 @@
     name="<?php echo $field->getName() ?>"
     value="<?php echo $field->getDisplayedData() ?>"
     <?php if ($field->isDisabled()): ?>disabled="disabled"<?php endif ?>
+    <?php echo $view['form']->attributes($attr) ?>
 />

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/number_field.php

@@ -3,4 +3,5 @@
     name="<?php echo $field->getName() ?>"
     value="<?php echo $field->getDisplayedData() ?>"
     <?php if ($field->isDisabled()): ?>disabled="disabled"<?php endif ?>
+    <?php echo $view['form']->attributes($attr) ?>
 />

+ 1 - 0
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/radio_field.php

@@ -4,4 +4,5 @@
     <?php if ($field->hasValue()): ?>value="<?php echo $field->getValue() ?>"<?php endif ?>
     <?php if ($field->isDisabled()): ?>disabled="disabled"<?php endif ?>
     <?php if ($field->isChecked()): ?>checked="checked"<?php endif ?>
+    <?php echo $view['form']->attributes($attr) ?>
 />

+ 6 - 1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/textarea_field.php

@@ -1,3 +1,8 @@
-<textarea id="<?php echo $field->getId() ?>" name="<?php echo $field->getName() ?>"<?php if ($field->isDisabled()): ?> disabled="disabled"<?php endif ?>><?php
+<textarea
+	id="<?php echo $field->getId() ?>"
+	name="<?php echo $field->getName() ?>"
+	<?php if ($field->isDisabled()): ?>disabled="disabled"<?php endif ?>
+	<?php echo $view['form']->attributes($attr) ?>
+><?php
     echo $view->escape($field->getDisplayedData())
 ?></textarea>

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

@@ -48,7 +48,7 @@
 {% block attributes %}
 {% spaceless %}
     {% for key, value in attr %}
-        {{ key }}="{{ value}}"
+        {{ key }}="{{ value }}"
     {% endfor %}
 {% endspaceless %}
 {% endblock attributes %}