From 2bbe7a64feafe303f7f8e1b0639640888ff1c55f Mon Sep 17 00:00:00 2001 From: James Cocker Date: Fri, 19 Jan 2024 10:31:04 +0000 Subject: [PATCH 1/2] Added config option to hide Content field --- README.md | 7 +++++++ _config/config.yml | 2 ++ src/Elements/ElementEmbeddedCode.php | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/README.md b/README.md index a4afb8f..103dbce 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,13 @@ See [Elemental modules by Dynamic](https://github.com/orgs/dynamic/repositories? ## Configuration +To hide the Content field: + +```yml +Dynamic\Elements\Embedded\Elements\ElementEmbeddedCode: + hide_content_field: true +``` + See [SilverStripe Elemental Configuration](https://github.com/silverstripe/silverstripe-elemental#configuration) ## Translations diff --git a/_config/config.yml b/_config/config.yml index 24f1cf1..45349b0 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -1,3 +1,5 @@ --- Name: silverstripeelemental-embedded-codeconfig --- +Dynamic\Elements\Embedded\Elements\ElementEmbeddedCode: + hide_content_field: false diff --git a/src/Elements/ElementEmbeddedCode.php b/src/Elements/ElementEmbeddedCode.php index 6e0c20a..d62d9f8 100644 --- a/src/Elements/ElementEmbeddedCode.php +++ b/src/Elements/ElementEmbeddedCode.php @@ -54,6 +54,10 @@ public function getCMSFields() ->setTitle('Embed Code') ); + if (ElementEmbeddedCode::config()->get('hide_content_field')) { + $fields->removeByName('Content'); + } + return $fields; } From 2a0582502d47423b77ef57c2a55e9ee1466e7ba1 Mon Sep 17 00:00:00 2001 From: James Cocker Date: Fri, 19 Jan 2024 11:24:47 +0000 Subject: [PATCH 2/2] Corrected config docs --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 103dbce..f487638 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,12 @@ See [Elemental modules by Dynamic](https://github.com/orgs/dynamic/repositories? To hide the Content field: ```yml +--- +After: + - "#silverstripeelemental-embedded-codeconfig" +--- Dynamic\Elements\Embedded\Elements\ElementEmbeddedCode: - hide_content_field: true + hide_content_field: true ``` See [SilverStripe Elemental Configuration](https://github.com/silverstripe/silverstripe-elemental#configuration)