Skip to content

Commit

Permalink
ignore /SearchForm endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed May 3, 2024
1 parent 130c0f0 commit fc46845
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/ActionsGridFieldItemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@ protected function getAvailableActions($actions)
return $list;
}

/**
* This module does not interact with the /schema/SearchForm endpoint
* and therefore all requests for these urls don't need any special treatement
*
* @return bool
*/
protected function isSearchFormRequest(): bool
{
if (!Controller::has_curr()) {
return false;
}
$curr = Controller::curr();
if ($curr) {
return str_contains($curr->getRequest()->getURL(), '/schema/SearchForm');
}
return false;
}

/**
* Called by CMSMain, typically in the CMS or in the SiteConfig admin
* CMSMain already uses getCMSActions so we are good to go with anything defined there
Expand All @@ -106,6 +124,11 @@ protected function getAvailableActions($actions)
*/
public function updateEditForm(Form $form)
{
// Ignore search form requests
if ($this->isSearchFormRequest()) {
return;
}

$actions = $form->Actions();

// We create a Drop-Up menu afterwards because it may already exist in the $CMSActions
Expand All @@ -123,6 +146,11 @@ public function updateEditForm(Form $form)
*/
public function updateFormActions($actions)
{
// Ignore search form requests
if ($this->isSearchFormRequest()) {
return;
}

$record = $this->owner->getRecord();

// We get the actions as defined on our record
Expand Down

0 comments on commit fc46845

Please sign in to comment.