From e7ded42c8f556561a6ff072c8e2c2678dd7083f2 Mon Sep 17 00:00:00 2001 From: Tim Bolender Date: Wed, 16 Apr 2014 23:11:24 +0200 Subject: [PATCH] Added possibility to edit calendar color --- Core/Frameworks/Baikal/Model/Calendar.php | 11 +++++++++++ Core/Frameworks/Formal/Form.php | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/Core/Frameworks/Baikal/Model/Calendar.php b/Core/Frameworks/Baikal/Model/Calendar.php index dfd0b02..4b16898 100644 --- a/Core/Frameworks/Baikal/Model/Calendar.php +++ b/Core/Frameworks/Baikal/Model/Calendar.php @@ -162,6 +162,17 @@ class Calendar extends \Flake\Core\Model\Db { ) ))); + $oMorpho->add(new \Formal\Element\Text(array( + "prop" => "calendarcolor", + "label" => "Calendar color", + "validation" => "color", + "popover" => array( + "title" => "Calendar color", + "content" => "This is the color that will be displayed in your CalDAV client.
". + "Must be supplied in format '#RRGGBBAA' with hexadecimal values. This value is optional.", + ) + ))); + $oMorpho->add(new \Formal\Element\Text(array( "prop" => "description", "label" => "Description" diff --git a/Core/Frameworks/Formal/Form.php b/Core/Frameworks/Formal/Form.php index d9ff63a..960baf3 100644 --- a/Core/Frameworks/Formal/Form.php +++ b/Core/Frameworks/Formal/Form.php @@ -314,6 +314,14 @@ class Form { return TRUE; } + + public function validateColor($sValue, \Formal\Form\Morphology $oMorpho, \Formal\Element $oElement) { + if(!empty($sValue) && !preg_match("/^#[a-fA-F0-9]{8}$/", $sValue)) { + return "" . $oElement->option("label") . " is not a valid color with format '#RRGGBBAA' in hexadecimal values."; + } + + return TRUE; + } public function postValue($sPropName) { $aData = \Flake\Util\Tools::POST("data");