Skip to content

Commit

Permalink
Forms: fixed missing token related exception in Form::create method w…
Browse files Browse the repository at this point in the history
…hen unit testing
  • Loading branch information
SKuipers committed Feb 13, 2025
1 parent 136ff45 commit a5e03e9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Forms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static function create($id, $action, $method = 'post', $class = 'standard
->setMethod($method);

// Add the CSRF token to all forms
$form->addHiddenValue('token', $container->get('token'));
$form->addHiddenValue('token', $container->has('token') ? $container->get('token') : '');

// Enable quick save by default on edit and settings pages
if ($form->checkActionList($action, ['settingsProcess', 'editProcess'])) {
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/Forms/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function setUp(): void
return $twig;
});

$container->share('token', 'test-token-value');

$service = new ViewServiceProvider();
$service->setContainer($container);
$service->register();
Expand Down

0 comments on commit a5e03e9

Please sign in to comment.