-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set the pseudo method to "delete" for "Delete" links. #1028
Conversation
This sets the `_method` hidden field in the post link form to "delete".
Should we target this to |
if so, then we should change the generated delete method in the controller to only allow the DELETE HTTP Method as well. |
It's very easy to miss specifying the Allowing |
@@ -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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldnt deleteLink() be cleaner to avoid the assoc array config overhead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been using this for the last decade in my Form helper(s):
public function deleteLink(string|HtmlStringable $title, array|string|null $url = null, array $options = []): string {
$options['method'] = 'delete';
if (!isset($options['class'])) {
$options['class'] = 'delete-link';
}
return $this->postLink($title, $url, $options);
}
I tend to avoid too much array config stuff in the templates themselves, and prefer speaking methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a deleteLink
method. We could add one though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I too was thinking of adding deleteLink()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have a deleteLink
method. We could add one though.
This sets the
_method
hidden field in the post link form todelete
.