[Form] Moved the access to templating helpers out of the choice loop for performance reasons (PHP +100ms)
This commit is contained in:
parent
0ef9acb479
commit
5dc3c39fd2
@ -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 foreach ($choices as $index => $choice): ?>
|
||||||
<?php if (is_array($choice)): ?>
|
<?php if (is_array($choice)): ?>
|
||||||
<optgroup label="<?php echo $view->escape($view['translator']->trans($index, array(), $translation_domain)) ?>">
|
<optgroup label="<?php echo $view->escape($translatorHelper->trans($index, array(), $translation_domain)) ?>">
|
||||||
<?php echo $view['form']->block('choice_widget_options', array('choices' => $choice)) ?>
|
<?php echo $formHelper->block('choice_widget_options', array('choices' => $choice)) ?>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
<?php else: ?>
|
<?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 endif ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
Reference in New Issue
Block a user