فهرست منبع

[Form] Adding a row() PHP helper equivalent to the Twig form_row() for outputting the label, error and tag of a form field.

Ryan Weaver 14 سال پیش
والد
کامیت
fac78859d5

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

@@ -2,7 +2,7 @@
 
 <div>
     <?php foreach ($field->getVisibleFields() as $child): ?>
-        <?php echo $view['form']->render($child, array(), array(), 'FrameworkBundle:Form:field_row.php.html') ?>
+        <?php echo $view['form']->row($child) ?>
     <?php endforeach; ?>
 </div>
 

+ 15 - 0
src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php

@@ -106,6 +106,21 @@ class FormHelper extends Helper
         )));
     }
 
+    /**
+     * Renders the entire form field "row".
+     *
+     * @param  FieldInterface $field
+     * @return string
+     */
+    public function row(/*FieldInterface*/ $field)
+    {
+        $template = 'FrameworkBundle:Form:field_row.php.html';
+
+        return $this->engine->render($template, array(
+            'field' => $field,
+        ));
+    }
+
     public function label(/*FieldInterface */$field, $label = false, array $parameters = array(), $template = null)
     {
         if (null === $template) {