Skip to content

Commit

Permalink
removed the possibility to pass a template to render_widget()
Browse files Browse the repository at this point in the history
This has been removed as the same can be achieved in a cleaner way:

 * Use plain HTML with calls to more granular Twig form functions
 * Create a macro if you really want to reuse the template snippet elsewhere
  • Loading branch information
fabpot committed Apr 28, 2011
1 parent 9f11ab4 commit 509f3dd
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/Symfony/Bridge/Twig/Extension/FormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,10 @@ public function renderRest(FormView $view, array $variables = array())
*
* @param FormView $view The view to render
* @param array $variables Additional variables passed to the template
* @param array|string $resources A resource or array of resources
*/
public function renderWidget(FormView $view, array $variables = array(), $resources = null)
public function renderWidget(FormView $view, array $variables = array())
{
if (null !== $resources && !is_array($resources)) {
$resources = array($resources);
}

return $this->render($view, 'widget', $variables, $resources);
return $this->render($view, 'widget', $variables);
}

/**
Expand All @@ -157,9 +152,9 @@ public function renderLabel(FormView $view, $label = null)
return $this->render($view, 'label', null === $label ? array() : array('label' => $label));
}

protected function render(FormView $view, $section, array $variables = array(), array $resources = null)
protected function render(FormView $view, $section, array $variables = array())
{
$templates = $this->getTemplates($view, $resources);
$templates = $this->getTemplates($view);
$blocks = $view->get('types');
foreach ($blocks as &$block) {
$block = $block.'_'.$section;
Expand All @@ -176,17 +171,16 @@ protected function render(FormView $view, $section, array $variables = array(),
throw new FormException(sprintf('Unable to render form as none of the following blocks exist: "%s".', implode('", "', $blocks)));
}

protected function getTemplate(FormView $view, $name, array $resources = null)
protected function getTemplate(FormView $view, $name)
{
$templates = $this->getTemplates($view, $resources);
$templates = $this->getTemplates($view);

return $templates[$name];
}

protected function getTemplates(FormView $view, array $resources = null)
protected function getTemplates(FormView $view)
{
// templates are looked for in the following resources:
// * resources provided directly into the function call
// * resources from the themes (and its parents)
// * default resources

Expand All @@ -201,9 +195,6 @@ protected function getTemplates(FormView $view, array $resources = null)
}
} while ($parent = $parent->getParent());

// local
$all = array_merge($all, null !== $resources ? (array) $resources : array());

$templates = array();
foreach ($all as $resource) {
if (!$resource instanceof \Twig_Template) {
Expand Down

0 comments on commit 509f3dd

Please sign in to comment.