EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
client page custom title, lead form custom title
Yuri Kuznetsov87ef57eb2923
diff --git a/application/Espo/Core/Utils/Client/ActionRenderer.php b/application/Espo/Core/Utils/Client/ActionRenderer.phpindex 1ae23fe670..ccb6d3ca43 100644--- a/application/Espo/Core/Utils/Client/ActionRenderer.php+++ b/application/Espo/Core/Utils/Client/ActionRenderer.php@@ -49,11 +49,12 @@ class ActionRendererpublic function write(Response $response, Params $params): void{$body = $this->render(- $params->getController(),- $params->getAction(),- $params->getData(),- $params->initAuth(),- $params->getScripts(),+ controller: $params->getController(),+ action: $params->getAction(),+ data: $params->getData(),+ initAuth: $params->initAuth(),+ scripts: $params->getScripts(),+ pageTitle: $params->getPageTitle(),);$securityParams = new SecurityParams(@@ -74,6 +75,7 @@ class ActionRenderer?array $data,bool $initAuth,array $scripts,+ ?string $pageTitle,): string {$encodedData = Json::encode($data);@@ -93,6 +95,7 @@ class ActionRenderer$params = new RenderParams(runScript: $script,scripts: $scripts,+ pageTitle: $pageTitle,);return $this->clientManager->render($params);diff --git a/application/Espo/Core/Utils/Client/ActionRenderer/Params.php b/application/Espo/Core/Utils/Client/ActionRenderer/Params.phpindex a1faea3a68..d5b82f5bdc 100644--- a/application/Espo/Core/Utils/Client/ActionRenderer/Params.php+++ b/application/Espo/Core/Utils/Client/ActionRenderer/Params.php@@ -43,6 +43,7 @@ class Paramsprivate array $frameAncestors = [];/** @var Script[] */private array $scripts = [];+ private ?string $pageTitle = null;/*** @param ?array<string, mixed> $data@@ -106,6 +107,17 @@ class Paramsreturn $obj;}+ /**+ * @since 9.1.0+ */+ public function withPageTitle(?string $pageTitle): self+ {+ $obj = clone $this;+ $obj->pageTitle = $pageTitle;++ return $obj;+ }+public function getController(): string{return $this->controller;@@ -146,4 +158,12 @@ class Params{return $this->scripts;}++ /**+ * @since 9.1.0+ */+ public function getPageTitle(): ?string+ {+ return $this->pageTitle;+ }}diff --git a/application/Espo/Core/Utils/Client/RenderParams.php b/application/Espo/Core/Utils/Client/RenderParams.phpindex 797215974d..9ec7d98fd3 100644--- a/application/Espo/Core/Utils/Client/RenderParams.php+++ b/application/Espo/Core/Utils/Client/RenderParams.php@@ -29,13 +29,16 @@namespace Espo\Core\Utils\Client;-class RenderParams+readonly class RenderParams{/**- * @param Script[] $scripts+ * @param ?string $runScript A JS run-script.+ * @param Script[] $scripts Scripts to include on the page.+ * @param ?string $pageTitle A page title. Since 9.1.0.*/public function __construct(- readonly public ?string $runScript = null,- readonly public array $scripts = [],+ public ?string $runScript = null,+ public array $scripts = [],+ public ?string $pageTitle = null,) {}}diff --git a/application/Espo/Core/Utils/ClientManager.php b/application/Espo/Core/Utils/ClientManager.phpindex ac3b096517..b606dade65 100644--- a/application/Espo/Core/Utils/ClientManager.php+++ b/application/Espo/Core/Utils/ClientManager.php@@ -165,10 +165,9 @@ class ClientManagerpublic function render(RenderParams $params): string{return $this->renderInternal(- $params->runScript,- null,- [],- $params->scripts+ runScript: $params->runScript,+ additionalScripts: $params->scripts,+ pageTitle: $params->pageTitle,);}@@ -180,7 +179,8 @@ class ClientManager?string $runScript = null,?string $htmlFilePath = null,array $vars = [],- array $additionalScripts = []+ array $additionalScripts = [],+ ?string $pageTitle = null,): string {$runScript ??= $this->runScript;@@ -235,7 +235,7 @@ class ClientManager$data = ['applicationId' => $this->applicationId,'apiUrl' => $this->apiUrl,- 'applicationName' => $this->config->get('applicationName', 'EspoCRM'),+ 'applicationName' => $pageTitle ?? $this->config->get('applicationName', 'EspoCRM'),'cacheTimestamp' => $cacheTimestamp,'appTimestamp' => $appTimestamp,'loaderCacheTimestamp' => Json::encode($loaderCacheTimestamp),diff --git a/application/Espo/Entities/LeadCapture.php b/application/Espo/Entities/LeadCapture.phpindex 6018ea19d3..d7c71dcf5f 100644--- a/application/Espo/Entities/LeadCapture.php+++ b/application/Espo/Entities/LeadCapture.php@@ -220,4 +220,9 @@ class LeadCapture extends Entity{return (bool) $this->get('formEnabled');}++ public function getFormTitle(): ?string+ {+ return $this->get('formTitle');+ }}diff --git a/application/Espo/EntryPoints/LeadCaptureForm.php b/application/Espo/EntryPoints/LeadCaptureForm.phpindex c67892e90e..7c14a3ed3b 100644--- a/application/Espo/EntryPoints/LeadCaptureForm.php+++ b/application/Espo/EntryPoints/LeadCaptureForm.php@@ -65,8 +65,15 @@ class LeadCaptureForm implements EntryPoint[$leadCapture, $data, $captchaScript] = $this->service->getData($id);- $params = new ActionRenderer\Params('controllers/lead-capture-form', 'show', $data);- $params = $params->withFrameAncestors($leadCapture->getFormFrameAncestors());+ $params = new ActionRenderer\Params(+ controller: 'controllers/lead-capture-form',+ action: 'show',+ data: $data,+ );++ $params = $params+ ->withFrameAncestors($leadCapture->getFormFrameAncestors())+ ->withPageTitle($leadCapture->getFormTitle());if ($captchaScript) {$params = $params->withScripts([new Script(source: $captchaScript)]);diff --git a/application/Espo/Resources/i18n/en_US/LeadCapture.json b/application/Espo/Resources/i18n/en_US/LeadCapture.jsonindex c6c2cd89ad..94d61d8afb 100644--- a/application/Espo/Resources/i18n/en_US/LeadCapture.json+++ b/application/Espo/Resources/i18n/en_US/LeadCapture.json@@ -28,6 +28,7 @@"formId": "Form ID","formEnabled": "Web Form","formUrl": "Form URL",+ "formTitle": "Form Title","formSuccessText": "Text to display after form submission","formText": "Text to display on form","formSuccessRedirectUrl": "URL to redirect to after form submission",diff --git a/application/Espo/Resources/layouts/LeadCapture/detail.json b/application/Espo/Resources/layouts/LeadCapture/detail.jsonindex 63a1954ae7..c6d416bc47 100644--- a/application/Espo/Resources/layouts/LeadCapture/detail.json+++ b/application/Espo/Resources/layouts/LeadCapture/detail.json@@ -15,7 +15,7 @@},{"rows": [- [{"name": "formEnabled"}, false],+ [{"name": "formEnabled"}, {"name": "formTitle"}],[{"name": "formText"}, {"name": "formSuccessText"}],[{"name": "formSuccessRedirectUrl"}, {"name": "formLanguage"}],[{"name": "formFrameAncestors"}, {"name": "formCaptcha"}]diff --git a/application/Espo/Resources/metadata/clientDefs/LeadCapture.json b/application/Espo/Resources/metadata/clientDefs/LeadCapture.jsonindex 53cb944fe0..1906648618 100644--- a/application/Espo/Resources/metadata/clientDefs/LeadCapture.json+++ b/application/Espo/Resources/metadata/clientDefs/LeadCapture.json@@ -154,6 +154,16 @@]}},+ "formTitle": {+ "visible": {+ "conditionGroup": [+ {+ "type": "isTrue",+ "attribute": "formEnabled"+ }+ ]+ }+ },"formText": {"visible": {"conditionGroup": [diff --git a/application/Espo/Resources/metadata/entityDefs/LeadCapture.json b/application/Espo/Resources/metadata/entityDefs/LeadCapture.jsonindex 1a93e81d89..938c366e2b 100644--- a/application/Espo/Resources/metadata/entityDefs/LeadCapture.json+++ b/application/Espo/Resources/metadata/entityDefs/LeadCapture.json@@ -132,6 +132,10 @@"type": "bool","audited": true},+ "formTitle": {+ "type": "varchar",+ "maxLength": 80+ },"formText": {"type": "text","tooltip": "optInConfirmationSuccessMessage"diff --git a/application/Espo/Tools/LeadCapture/FormService.php b/application/Espo/Tools/LeadCapture/FormService.phpindex 6f897e9966..a597cdaab7 100644--- a/application/Espo/Tools/LeadCapture/FormService.php+++ b/application/Espo/Tools/LeadCapture/FormService.php@@ -417,6 +417,7 @@ class FormService'language' => $languageData,'successText' => $successText,'text' => $text,+ 'title' => $leadCapture->getFormTitle(),'config' => (object) $config,'appParams' => (object) $appParams,];diff --git a/client/src/views/lead-capture/form.js b/client/src/views/lead-capture/form.jsindex 6f1d95d508..af7586cad5 100644--- a/client/src/views/lead-capture/form.js+++ b/client/src/views/lead-capture/form.js@@ -70,6 +70,7 @@ export default class LeadCaptureFormView extends View {* appParams: Record,* captchaKey: boolean,* isDark: boolean,+ * title: string|null,* },* }} options*/