Skip to content

Commit

Permalink
[TwigBundle] added a form_row() function
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jan 5, 2011
1 parent b5e26d9 commit f946355
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Symfony/Bundle/TwigBundle/Extension/FormExtension.php
Expand Up @@ -73,6 +73,7 @@ public function getFunctions()
'form_errors' => new \Twig_Function_Method($this, 'renderErrors', array('is_safe' => array('html'))),
'form_label' => new \Twig_Function_Method($this, 'renderLabel', array('is_safe' => array('html'))),
'form_data' => new \Twig_Function_Method($this, 'renderData', array('is_safe' => array('html'))),
'form_row' => new \Twig_Function_Method($this, 'renderRow', array('is_safe' => array('html'))),
);
}

Expand All @@ -90,6 +91,22 @@ public function renderEnctype(Form $form)
return $form->isMultipart() ? 'enctype="multipart/form-data"' : '';
}

/**
* Renders a field row.
*
* @param FieldInterface $field The field to render as a row
*/
public function renderRow(FieldInterface $field)
{
if (null === $this->templates) {
$this->templates = $this->resolveResources($this->resources);
}

return $this->templates['field_row']->renderBlock('field_row', array(
'child' => $field,
));
}

/**
* Renders the HTML for an individual form field
*
Expand Down

0 comments on commit f946355

Please sign in to comment.