Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-15542

The api ignores option_group_id when creating a new custom_field.

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.5
    • Fix Version/s: 4.6
    • Component/s: CiviCRM API
    • Labels:
    • Documentation Required?:
      None

      Description

      If you use the api to create a custom field, like

      $api_result = civicrm_api3('CustomField', 'create', array(
      'custom_group_id' => 10, // some existing custom group ID
      'name' => 'voorkeursafdeling',
      'label' => 'Voorkeursafdeling',
      'data_type' => 'String',
      'html_type' => 'Select',
      'is_required' => 0,
      'is_searchable' => 1,
      'weight' => 2,
      'is_active' => 1,
      'option_group_id' => 92, // some existing option group id
      ));

      it ignores the option_group_id, and just creates a new (empty) option group. You can work around this problem by updating the custom field after creation:

      $custom_field_id = $api_result['id'];
      civicrm_api3('CustomField', 'create', array(
      'id' => $custom_field_id,
      'option_group_id' => 92));

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                atif.shaikh Atif Shaikh
                Reporter:
                johanv Johan Vervloet
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: