$params['option_group_id'] = CRM_Core_DAO::getFieldValue(
'CRM_Core_DAO_OptionGroup', 'report_template', 'id', 'name'
);
+ if (!empty($params['component_id']) && !is_numeric($params['component_id'])) {
+ $components = CRM_Core_PseudoConstant::get('CRM_Core_DAO_OptionValue', 'component_id', array('onlyActive' => FALSE, 'labelColumn' => 'name'));
+ $params['component_id'] = array_search($params['component_id'], $components);
+ }
return civicrm_api3_option_value_create($params);
}
-/*
+/**
* Adjust Metadata for Create action
*
* The metadata is used for setting defaults, documentation & validation
function _civicrm_api3_report_template_create_spec(&$params) {
require_once 'api/v3/OptionValue.php';
_civicrm_api3_option_value_create_spec($params);
- $params['weight']['api.default'] = 'next';
$params['value']['api.aliases'] = array('report_url');
$params['name']['api.aliases'] = array('class_name');
+ $params['option_group_id']['api.default'] = CRM_Core_DAO::getFieldValue(
+ 'CRM_Core_DAO_OptionGroup', 'report_template', 'id', 'name'
+ );
// $params['component']['api.required'] = TRUE;
}