+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2015 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2015
+ * @copyright CiviCRM LLC (c) 2004-2016
*/
/**
}
}
+ $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.
*/