<?php
-// $Id$
/*
+--------------------------------------------------------------------+
*/
function civicrm_api3_custom_field_create($params) {
- if (!(CRM_Utils_Array::value('option_type', $params))) {
- if (CRM_Utils_Array::value('id', $params)) {
- $params['option_type'] = 2;
- }
- else {
- $params['option_type'] = 1;
- }
- }
-
-
// Array created for passing options in params
if (isset($params['option_values']) && is_array($params['option_values'])) {
foreach ($params['option_values'] as $key => $value) {
/**
* Adjust Metadata for Create action
- *
+ *
* @param array $params array or parameters determined by getfields
*/
function _civicrm_api3_custom_field_create_spec(&$params) {
$params['label']['api.required'] = 1;
$params['custom_group_id']['api.required'] = 1;
+ $params['is_active']['api.default'] = 1;
+ $params['option_type'] = array(
+ 'title' => 'This (boolean) field tells the BAO to create an option group for the field if the field type is appropriate',
+ 'api.default' => 1,
+ 'type' => CRM_Utils_Type::T_BOOL,
+ );
+ $params['data_type']['api.default'] = 'String';
+ $params['is_active']['api.default'] = 1;
}
/**
}
/*
- * Helper function to validate custom field values
- *
+ * Helper function to validate custom field values
+ *
* @params Array $params Custom fields with values
- * @params Array $errors Reference fields to be check with
- * @params Boolean $checkForDisallowed Check for disallowed elements
+ * @params Array $errors Reference fields to be check with
+ * @params Boolean $checkForDisallowed Check for disallowed elements
* in params
* @params Boolean $checkForRequired Check for non present required elements
* in params
/**
* Helper function to validate custom field value
- *
+ *
* @params String $fieldName Custom field name (eg: custom_8 )
* @params Mixed $value Field value to be validate
* @params Array $fieldDetails Field Details
}
$query = "
-SELECT count(*)
+SELECT count(*)
FROM civicrm_state_province
WHERE id IN ('" . implode("','", $value) . "')";
if (CRM_Core_DAO::singleValueQuery($query) < count($value)) {