Fix settings form being sent as PUT
FormHelper adds a hidden _method=PUT for persisted entities, which the POST-only admin:settings route rejected with a MissingRouteException. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c41005e6a2
commit
9dad7ab939
2 files changed
+12
-1
No files matched your search
@@ -127,7 +127,7 @@ $url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $ad
|
|||||||
|
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<h2><?= __('Einstellungen') ?></h2>
|
<h2><?= __('Einstellungen') ?></h2>
|
||||||
<?= $this->Form->create($poll, ['url' => $url('admin:settings')]) ?>
|
<?= $this->Form->create($poll, ['url' => $url('admin:settings'), 'type' => 'post']) ?>
|
||||||
<?= $this->Form->control('title', ['label' => __('Titel'), 'maxlength' => 200]) ?>
|
<?= $this->Form->control('title', ['label' => __('Titel'), 'maxlength' => 200]) ?>
|
||||||
<?= $this->Form->control('is_active', [
|
<?= $this->Form->control('is_active', [
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
|
|||||||
@@ -49,6 +49,17 @@ class AdminControllerTest extends TestCase
|
|||||||
$this->assertHeaderContains('X-Robots-Tag', 'noindex');
|
$this->assertHeaderContains('X-Robots-Tag', 'noindex');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSettingsFormPostsAndSaves(): void
|
||||||
|
{
|
||||||
|
[$poll, $token] = $this->createPoll('Alt');
|
||||||
|
$this->get("/admin/$token");
|
||||||
|
$this->assertResponseNotContains('name="_method" value="PUT"', 'settings form must not override method');
|
||||||
|
|
||||||
|
$this->post("/admin/$token/settings", ['title' => 'Neu', 'is_active' => '1', 'show_results_to_participants' => '0']);
|
||||||
|
$this->assertRedirect(['_name' => 'admin', 'token' => $token]);
|
||||||
|
$this->assertSame('Neu', $this->pollsTable()->get($poll->id)->title);
|
||||||
|
}
|
||||||
|
|
||||||
public function testTokenOfOtherPollCannotAccessSlides(): void
|
public function testTokenOfOtherPollCannotAccessSlides(): void
|
||||||
{
|
{
|
||||||
[$pollA] = $this->createPoll('A');
|
[$pollA] = $this->createPoll('A');
|
||||||
|
|||||||
Reference in new issue
Block a user