FIX: Search Form

This commit is contained in:
Tony Air 2024-08-08 19:05:17 +02:00
parent 3b770f2289
commit f77f7acd55

View File

@ -2,7 +2,10 @@
namespace A2nt\CMSNiceties\Extensions;
use A2nt\ElementalBasics\Models\TeamMember;
use DNADesign\Elemental\Models\ElementalArea;
use DNADesign\Elemental\Models\ElementContent;
use DNADesign\ElementalUserForms\Control\ElementFormController;
use Page;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
@ -153,7 +156,13 @@ class PageControllerEx extends Extension
RequiredFields::create(['q'])
)->setFormMethod('GET');
$form->setLegend('Search ' . $config->getField('Title') . ' Website');
$homePage = SiteTree::get()->filter('URLSegment', 'home')->first();
if ($homePage) {
$link = $homePage->Link();
$link = ($link === '/') ? '/home/' : $link;
$form->setFormAction($link);
}
$form->setLegend('Search at ' . $config->getField('Title'));
return $form;
}