From 9082db159c62432716a82675053eeb637501f440 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Fri, 17 May 2019 11:29:25 +1200 Subject: [PATCH] FIX Add CMS configurable title for iframe to tell screenreaders it contains frame content --- src/IFramePage.php | 9 ++++++++- templates/SilverStripe/IFrame/Layout/IFramePage.ss | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/IFramePage.php b/src/IFramePage.php index fffe512..6a64a2f 100644 --- a/src/IFramePage.php +++ b/src/IFramePage.php @@ -8,6 +8,8 @@ use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\NumericField; use SilverStripe\Forms\HTMLEditor\HtmlEditorField; use SilverStripe\ORM\FieldType\DBField; +use SilverStripe\ORM\ValidationException; +use SilverStripe\ORM\ValidationResult; /** * Iframe page type embeds an iframe of URL of choice into the page. @@ -18,6 +20,7 @@ class IFramePage extends Page { private static $db = array( 'IFrameURL' => 'Text', + 'IFrameTitle' => 'Varchar', 'AutoHeight' => 'Boolean(1)', 'AutoWidth' => 'Boolean(1)', 'FixedHeight' => 'Int(500)', @@ -45,7 +48,11 @@ class IFramePage extends Page $fields = parent::getCMSFields(); $fields->removeFieldFromTab('Root.Main', 'Content'); - $fields->addFieldToTab('Root.Main', $url = new TextField('IFrameURL', 'Iframe URL')); + $fields->addFieldsToTab('Root.Main', [ + $url = TextField::create('IFrameURL', 'Iframe URL'), + TextField::create('IFrameTitle', 'Iframe Title') + ->setDescription(_t(__CLASS__ . '.TITLE_DESCRIPTION', 'Used to identify the contents of the Iframe')), + ]); $url->setRightTitle( DBField::create_field( 'HTMLText', diff --git a/templates/SilverStripe/IFrame/Layout/IFramePage.ss b/templates/SilverStripe/IFrame/Layout/IFramePage.ss index 3a4fe24..e132d50 100644 --- a/templates/SilverStripe/IFrame/Layout/IFramePage.ss +++ b/templates/SilverStripe/IFrame/Layout/IFramePage.ss @@ -9,7 +9,7 @@
<%t SilverStripe\\IFrame\\IFramePage.ExternalNote "Please note the following section of content is possibly being delivered from an external source (IFRAME in HTML terms), and may present unusual experiences for screen readers." %>
- + <% end_if %> $BottomContent