Skip to content

Commit

Permalink
[Form] Moved the access to templating helpers out of the choice loop …
Browse files Browse the repository at this point in the history
…for performance reasons (PHP +100ms)
  • Loading branch information
webmozart committed Jul 21, 2012
1 parent 0ef9acb commit 5dc3c39
Showing 1 changed file with 5 additions and 3 deletions.
@@ -1,9 +1,11 @@
<?php $translatorHelper = $view['translator']; // outside of the loop for performance reasons! ?>
<?php $formHelper = $view['form']; ?>
<?php foreach ($choices as $index => $choice): ?>
<?php if (is_array($choice)): ?>
<optgroup label="<?php echo $view->escape($view['translator']->trans($index, array(), $translation_domain)) ?>">
<?php echo $view['form']->block('choice_widget_options', array('choices' => $choice)) ?>
<optgroup label="<?php echo $view->escape($translatorHelper->trans($index, array(), $translation_domain)) ?>">
<?php echo $formHelper->block('choice_widget_options', array('choices' => $choice)) ?>
</optgroup>
<?php else: ?>
<option value="<?php echo $view->escape($choice->value) ?>"<?php if ($choice->isSelected($value)): ?> selected="selected"<?php endif?>><?php echo $view->escape($view['translator']->trans($choice->label, array(), $translation_domain)) ?></option>
<option value="<?php echo $view->escape($choice->value) ?>"<?php if ($choice->isSelected($value)): ?> selected="selected"<?php endif?>><?php echo $view->escape($translatorHelper->trans($choice->label, array(), $translation_domain)) ?></option>
<?php endif ?>
<?php endforeach ?>

0 comments on commit 5dc3c39

Please sign in to comment.