projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #6574 from eileenmcnaughton/CRM-17070
[civicrm-core.git]
/
api
/
v3
/
CustomField.php
diff --git
a/api/v3/CustomField.php
b/api/v3/CustomField.php
index f18237e4773a123dc8685095069c0f20114e8f68..2cea880732ab606f03fbd7a5d59564cd27d6a33c 100644
(file)
--- a/
api/v3/CustomField.php
+++ b/
api/v3/CustomField.php
@@
-1,9
+1,9
@@
<?php
/*
+--------------------------------------------------------------------+
<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.
6
|
+ | CiviCRM version 4.
7
|
+--------------------------------------------------------------------+
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-201
4
|
+ | Copyright CiviCRM LLC (c) 2004-201
5
|
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
@@
-48,7
+48,18
@@
function civicrm_api3_custom_field_create($params) {
// Array created for passing options in params.
if (isset($params['option_values']) && is_array($params['option_values'])) {
// Array created for passing options in params.
if (isset($params['option_values']) && is_array($params['option_values'])) {
+ $weight = 0;
foreach ($params['option_values'] as $key => $value) {
foreach ($params['option_values'] as $key => $value) {
+ // Translate simple key/value pairs into full-blown option values
+ if (!is_array($value)) {
+ $value = array(
+ 'label' => $value,
+ 'value' => $key,
+ 'is_active' => 1,
+ 'weight' => $weight,
+ );
+ $key = $weight++;
+ }
$params['option_label'][$key] = $value['label'];
$params['option_value'][$key] = $value['value'];
$params['option_status'][$key] = $value['is_active'];
$params['option_label'][$key] = $value['label'];
$params['option_value'][$key] = $value['value'];
$params['option_status'][$key] = $value['is_active'];
@@
-80,8
+91,14
@@
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['label']['api.required'] = 1;
$params['custom_group_id']['api.required'] = 1;
$params['is_active']['api.default'] = 1;
+ $params['option_values'] = array(
+ 'title' => 'Option Values',
+ 'description' => "Pass an array of options (value => label) to create this field's option values",
+ );
+ // TODO: Why expose this to the api at all?
$params['option_type'] = array(
$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',
+ 'title' => 'Option Type',
+ 'description' => '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_BOOLEAN,
);
'api.default' => 1,
'type' => CRM_Utils_Type::T_BOOLEAN,
);