X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FAdmin%2FForm%2FOptions.php;h=e386f1870e26cd56d368f3de2d4ff81bcd83c213;hb=57aa6ec1bba6343ea0ee3cb98753fabe37187bf2;hp=25db9ff2737b6774611939302fd29dfb2776a749;hpb=90afa3f8b2bd0cd6c38c02254cfd5aeb5807b2c3;p=civicrm-core.git diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php index 25db9ff273..e386f1870e 100644 --- a/CRM/Admin/Form/Options.php +++ b/CRM/Admin/Form/Options.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 */ /** @@ -376,9 +376,35 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { } } + $optionGroup = self::getOptionGroupDataType($self->_gName); + if ($dataType) { + $validate = CRM_Utils_Type::validate($fields['value'], $dataType, FALSE); + if (!$validate) { + CRM_Core_Session::setStatus( + ts('Data Type of the value field for this option value does not match ' . $dataType), + ts('Value field Data Type mismatch')); + } + } return $errors; } + /** + * Get the DataType for a specified Option Group. + * + * @param string $optionGroupName name of the option group + * + * @return string|null + */ + public static function getOptionGroupDataType($optionGroupName) { + $optionGroup = civicrm_api3('OptionGroup', 'get', array( + 'sequential' => 1, + 'name' => $optionGroupName, + )); + + $dataType = CRM_Core_BAO_OptionGroup::getDataType($optionGroup['id']); + return $dataType; + } + /** * Process the form submission. */