[Form] Renamed the internal FormView variables "types" and "full_block_name"
This commit is contained in:
parent
6b17640647
commit
eeb66dd2ef
@ -71,11 +71,11 @@ class FormType extends AbstractType
|
|||||||
if ('' !== ($parentFullName = $view->parent->vars['full_name'])) {
|
if ('' !== ($parentFullName = $view->parent->vars['full_name'])) {
|
||||||
$id = sprintf('%s_%s', $view->parent->vars['id'], $name);
|
$id = sprintf('%s_%s', $view->parent->vars['id'], $name);
|
||||||
$fullName = sprintf('%s[%s]', $parentFullName, $name);
|
$fullName = sprintf('%s[%s]', $parentFullName, $name);
|
||||||
$fullBlockName = sprintf('%s_%s', $view->parent->vars['full_block_name'], $blockName);
|
$uniqueBlockPrefix = sprintf('%s_%s', $view->parent->vars['unique_block_prefix'], $blockName);
|
||||||
} else {
|
} else {
|
||||||
$id = $name;
|
$id = $name;
|
||||||
$fullName = $name;
|
$fullName = $name;
|
||||||
$fullBlockName = '_' . $blockName;
|
$uniqueBlockPrefix = '_' . $blockName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Complex fields are read-only if they themselves or their parents are.
|
// Complex fields are read-only if they themselves or their parents are.
|
||||||
@ -89,7 +89,7 @@ class FormType extends AbstractType
|
|||||||
} else {
|
} else {
|
||||||
$id = $name;
|
$id = $name;
|
||||||
$fullName = $name;
|
$fullName = $name;
|
||||||
$fullBlockName = '_' . $blockName;
|
$uniqueBlockPrefix = '_' . $blockName;
|
||||||
|
|
||||||
// Strip leading underscores and digits. These are allowed in
|
// Strip leading underscores and digits. These are allowed in
|
||||||
// form names, but not in HTML4 ID attributes.
|
// form names, but not in HTML4 ID attributes.
|
||||||
@ -97,10 +97,11 @@ class FormType extends AbstractType
|
|||||||
$id = ltrim($id, '_0123456789');
|
$id = ltrim($id, '_0123456789');
|
||||||
}
|
}
|
||||||
|
|
||||||
$types = array();
|
$blockPrefixes = array();
|
||||||
for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) {
|
for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) {
|
||||||
array_unshift($types, $type->getName());
|
array_unshift($blockPrefixes, $type->getName());
|
||||||
}
|
}
|
||||||
|
$blockPrefixes[] = $uniqueBlockPrefix;
|
||||||
|
|
||||||
if (!$translationDomain) {
|
if (!$translationDomain) {
|
||||||
$translationDomain = 'messages';
|
$translationDomain = 'messages';
|
||||||
@ -111,7 +112,6 @@ class FormType extends AbstractType
|
|||||||
'id' => $id,
|
'id' => $id,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'full_name' => $fullName,
|
'full_name' => $fullName,
|
||||||
'full_block_name' => $fullBlockName,
|
|
||||||
'read_only' => $readOnly,
|
'read_only' => $readOnly,
|
||||||
'errors' => $form->getErrors(),
|
'errors' => $form->getErrors(),
|
||||||
'valid' => $form->isBound() ? $form->isValid() : true,
|
'valid' => $form->isBound() ? $form->isValid() : true,
|
||||||
@ -127,7 +127,8 @@ class FormType extends AbstractType
|
|||||||
'attr' => $options['attr'],
|
'attr' => $options['attr'],
|
||||||
'label_attr' => $options['label_attr'],
|
'label_attr' => $options['label_attr'],
|
||||||
'compound' => $form->getConfig()->getCompound(),
|
'compound' => $form->getConfig()->getCompound(),
|
||||||
'types' => $types,
|
'block_prefixes' => $blockPrefixes,
|
||||||
|
'unique_block_prefix' => $uniqueBlockPrefix,
|
||||||
'translation_domain' => $translationDomain,
|
'translation_domain' => $translationDomain,
|
||||||
// Using the block name here speeds up performance in collection
|
// Using the block name here speeds up performance in collection
|
||||||
// forms, where each entry has the same full block name.
|
// forms, where each entry has the same full block name.
|
||||||
@ -135,7 +136,7 @@ class FormType extends AbstractType
|
|||||||
// collection form have different types (dynamically), they should
|
// collection form have different types (dynamically), they should
|
||||||
// be rendered differently.
|
// be rendered differently.
|
||||||
// https://github.com/symfony/symfony/issues/5038
|
// https://github.com/symfony/symfony/issues/5038
|
||||||
'cache_key' => $fullBlockName . '_' . $form->getConfig()->getType()->getName(),
|
'cache_key' => $uniqueBlockPrefix . '_' . $form->getConfig()->getType()->getName(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
|
|||||||
*/
|
*/
|
||||||
class FormRenderer implements FormRendererInterface
|
class FormRenderer implements FormRendererInterface
|
||||||
{
|
{
|
||||||
const CACHE_KEY_VAR = 'full_block_name';
|
const CACHE_KEY_VAR = 'unique_block_prefix';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FormRendererEngineInterface
|
* @var FormRendererEngineInterface
|
||||||
@ -173,10 +173,9 @@ class FormRenderer implements FormRendererInterface
|
|||||||
// Calculate the hierarchy of template blocks and start on
|
// Calculate the hierarchy of template blocks and start on
|
||||||
// the bottom level of the hierarchy (= "_<id>_<section>" block)
|
// the bottom level of the hierarchy (= "_<id>_<section>" block)
|
||||||
$blockNameHierarchy = array();
|
$blockNameHierarchy = array();
|
||||||
foreach ($view->vars['types'] as $type) {
|
foreach ($view->vars['block_prefixes'] as $blockNamePrefix) {
|
||||||
$blockNameHierarchy[] = $type . '_' . $blockNameSuffix;
|
$blockNameHierarchy[] = $blockNamePrefix . '_' . $blockNameSuffix;
|
||||||
}
|
}
|
||||||
$blockNameHierarchy[] = $view->vars['full_block_name'] . '_' . $blockNameSuffix;
|
|
||||||
$hierarchyLevel = count($blockNameHierarchy) - 1;
|
$hierarchyLevel = count($blockNameHierarchy) - 1;
|
||||||
|
|
||||||
$hierarchyInit = true;
|
$hierarchyInit = true;
|
||||||
|
Reference in New Issue
Block a user