8000 Add block prefix to csrf token field · symfony/symfony@0f369c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f369c9

Browse files
Add block prefix to csrf token field
1 parent 6ca3974 commit 0f369c9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ public function finishView(FormView $view, FormInterface $form, array $options)
9090
$tokenId = $options['csrf_token_id'] ?: ($form->getName() ?: \get_class($form->getConfig()->getType()->getInnerType()));
9191
$data = (string) $options['csrf_token_manager']->getToken($tokenId);
9292

93-
$csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, array(
93+
$csrfForm = $factory->createNamed($options['csrf_field_name'], 'Symfony\Component\Form\Extension\Core\Type\HiddenType', $data, [
94+
'block_prefix' => 'token',
9495
'mapped' => false,
95-
));
96+
]);
9697

9798
$view->children[$options['csrf_field_name']] = $csrfForm->createView($view);
9899
}
@@ -103,20 +104,20 @@ public function finishView(FormView $view, FormInterface $form, array $options)
103104
*/
104105
public function configureOptions(OptionsResolver $resolver)
105106
{
106-
$resolver->setDefaults(array(
107+
$resolver->setDefaults([
107108
'csrf_protection' => $this->defaultEnabled,
108109
'csrf_field_name' => $this->defaultFieldName,
109110
'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.',
110111
'csrf_token_manager' => $this->defaultTokenManager,
111112
'csrf_token_id' => null,
112-
));
113+
]);
113114
}
114115

115116
/**
116117
* {@inheritdoc}
117118
*/
118119
public static function getExtendedTypes(): iterable
119120
{
120-
return array(FormType::class);
121+
return [FormType::class];
121122
}
122123
}

0 commit comments

Comments
 (0)
0