<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | 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
- * $Id$
- *
+ * @copyright CiviCRM LLC (c) 2004-2016
*/
/**
- * This class generates form components for Options
- *
+ * This class generates form components for Options.
*/
class CRM_Admin_Form_Options extends CRM_Admin_Form {
/**
* Pre-process
- *
- * @return void
*/
public function preProcess() {
parent::preProcess();
/**
* Set default values for the form.
- *
- * @return void
*/
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
/**
* Build the form object.
- *
- * @return void
*/
public function buildQuickForm() {
parent::buildQuickForm();
}
}
+ $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;
}
/**
- * Process the form submission.
+ * Get the DataType for a specified Option Group.
*
+ * @param string $optionGroupName name of the option group
*
- * @return void
+ * @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.
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {