Skip to content

Commit

Permalink
Set pseudo method to "delete" for "Delete" links.
Browse files Browse the repository at this point in the history
This sets the `_method` hidden field in the post link form to "delete".
  • Loading branch information
ADmad committed Jan 17, 2025
1 parent e94334b commit 2ee6980
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ indent_size = 2

[*.twig]
insert_final_newline = false

[tests/comparisons/Template/*.php]
insert_final_newline = false
9 changes: 8 additions & 1 deletion templates/bake/Template/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', {{ pk|raw }}]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', {{ pk|raw }}]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', {{ pk|raw }}], ['confirm' => __('Are you sure you want to delete # {0}?', {{ pk|raw }})]) ?>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', {{ pk|raw }}],
[
'method' => 'delete',
'confirm' => __('Are you sure you want to delete # {0}?', {{ pk|raw }}),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
9 changes: 8 additions & 1 deletion templates/bake/Template/view.twig
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => '{{ details.controller }}', 'action' => 'view', {{ otherPk|raw }}]) ?>
<?= $this->Html->link(__('Edit'), ['controller' => '{{ details.controller }}', 'action' => 'edit', {{ otherPk|raw }}]) ?>
<?= $this->Form->postLink(__('Delete'), ['controller' => '{{ details.controller }}', 'action' => 'delete', {{ otherPk|raw }}], ['confirm' => __('Are you sure you want to delete # {0}?', {{ otherPk|raw }})]) ?>
<?= $this->Form->postLink(
__('Delete'),
['controller' => '{{ details.controller }}', 'action' => 'delete', {{ otherPk|raw }}],
[
'method' => 'delete',
'confirm' => __('Are you sure you want to delete # {0}?', {{ otherPk|raw }}),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
9 changes: 8 additions & 1 deletion tests/comparisons/Template/testBakeIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $templateTaskComment->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $templateTaskComment->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $templateTaskComment->id], ['confirm' => __('Are you sure you want to delete # {0}?', $templateTaskComment->id)]) ?>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $templateTaskComment->id],
[
'method' => 'delete',
'confirm' => __('Are you sure you want to delete # {0}?', $templateTaskComment->id),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
9 changes: 8 additions & 1 deletion tests/comparisons/Template/testBakeIndexHiddenFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $hiddenField->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $hiddenField->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $hiddenField->id], ['confirm' => __('Are you sure you want to delete # {0}?', $hiddenField->id)]) ?>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $hiddenField->id],
[
'method' => 'delete',
'confirm' => __('Are you sure you want to delete # {0}?', $hiddenField->id),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
9 changes: 8 additions & 1 deletion tests/comparisons/Template/testBakeIndexWithEnumNoLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $article->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $article->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $article->id], ['confirm' => __('Are you sure you want to delete # {0}?', $article->id)]) ?>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $article->id],
[
'method' => 'delete',
'confirm' => __('Are you sure you want to delete # {0}?', $article->id),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $bakeUser->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $bakeUser->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $bakeUser->id], ['confirm' => __('Are you sure you want to delete # {0}?', $bakeUser->id)]) ?>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $bakeUser->id],
[
'method' => 'delete',
'confirm' => __('Are you sure you want to delete # {0}?', $bakeUser->id),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
9 changes: 8 additions & 1 deletion tests/comparisons/Template/testBakeIndexWithIndexLimit.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@
<td class="actions">
<?= $this->Html->link(__('View'), ['action' => 'view', $templateTaskComment->id]) ?>
<?= $this->Html->link(__('Edit'), ['action' => 'edit', $templateTaskComment->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $templateTaskComment->id], ['confirm' => __('Are you sure you want to delete # {0}?', $templateTaskComment->id)]) ?>
<?= $this->Form->postLink(
__('Delete'),
['action' => 'delete', $templateTaskComment->id],
[
'method' => 'delete',
'confirm' => __('Are you sure you want to delete # {0}?', $templateTaskComment->id),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
9 changes: 8 additions & 1 deletion tests/comparisons/Template/testBakeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'Articles', 'action' => 'view', $article->id]) ?>
<?= $this->Html->link(__('Edit'), ['controller' => 'Articles', 'action' => 'edit', $article->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['controller' => 'Articles', 'action' => 'delete', $article->id], ['confirm' => __('Are you sure you want to delete # {0}?', $article->id)]) ?>
<?= $this->Form->postLink(
__('Delete'),
['controller' => 'Articles', 'action' => 'delete', $article->id],
[
'method' => 'delete',
'confirm' => __('Are you sure you want to delete # {0}?', $article->id),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down
9 changes: 8 additions & 1 deletion tests/comparisons/Template/testBakeViewEnumNoLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@
<td class="actions">
<?= $this->Html->link(__('View'), ['controller' => 'tags', 'action' => 'view', $tag->id]) ?>
<?= $this->Html->link(__('Edit'), ['controller' => 'tags', 'action' => 'edit', $tag->id]) ?>
<?= $this->Form->postLink(__('Delete'), ['controller' => 'tags', 'action' => 'delete', $tag->id], ['confirm' => __('Are you sure you want to delete # {0}?', $tag->id)]) ?>
<?= $this->Form->postLink(
__('Delete'),
['controller' => 'tags', 'action' => 'delete', $tag->id],
[
'method' => 'delete',
'confirm' => __('Are you sure you want to delete # {0}?', $tag->id),
]
) ?>
</td>
</tr>
<?php endforeach; ?>
Expand Down

0 comments on commit 2ee6980

Please sign in to comment.