I have a "Select list" within a Contribution Form. I want to populate the "Select List" with Custom Field values.

I have created the Custom Group under Contacts, so i want to search all contacts and get the custom field "Title" from that Custom group.

Then depending on the "Option" selected i want field values to populate.

I have tried to use the:

hook_civicrm_fieldOptions but its not working (https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_fieldOptions/).

Any advise on how to do this?


This is the HTML for field i want to populate:

<tr class="custom_field-row custom_276_-1-row">
    <td class="label"><label for="custom_276_-1">Proc Fee</label>
      <a class="helpicon" title="Proc Fee Help" aria-label="Proc Fee Help" href="#" onclick="CRM.help(&quot;Proc Fee&quot;, {&quot;id&quot;:276,&quot;file&quot;:&quot;CRM\/Custom\/Form\/CustomField&quot;}); return false;">&nbsp;</a>    </td>
    <td class="html-adjust">
      <div class="select2-container crm-select2 crm-form-select" id="s2id_custom_276_-1" style="width: 195px;"><a href="javascript:void(0)" class="select2-choice select2-default" tabindex="-1">   <span class="select2-chosen" id="select2-chosen-6">- none -</span><abbr class="select2-search-choice-close"></abbr>   <span class="select2-arrow" role="presentation"><b role="presentation"></b></span></a><label for="s2id_autogen6" class="select2-offscreen">Proc Fee</label><input class="select2-focusser select2-offscreen" type="text" aria-haspopup="true" role="button" aria-labelledby="select2-chosen-6" id="s2id_autogen6"><div class="select2-drop select2-display-none crm-container select2-with-searchbox">   <div class="select2-search">       <label for="s2id_autogen6_search" class="select2-offscreen">Proc Fee</label>       <input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" class="select2-input" role="combobox" aria-expanded="true" aria-autocomplete="list" aria-owns="select2-results-6" id="s2id_autogen6_search" placeholder="">   </div>   <ul class="select2-results" role="listbox" id="select2-results-6">   </ul></div></div><select class="crm-select2 crm-form-select" data-crm-custom="Commission:Proc_Fee" data-api-entity="Contribution" data-api-field="custom_276" data-option-edit-path="civicrm/admin/options/proc_fee_20191113181638" name="custom_276_-1" id="custom_276_-1" tabindex="-1" title="Proc Fee" style="display: none;">
    <option value="">- none -</option>
    <option value="accordpt30">Accord - PT - 0.30%</option>
    <option value="accordresidirect045">Accord - Resi - Direct - 0.45%</option>
</select> <a href="/civicrm/admin/options/proc_fee_20191113181638?reset=1" class="crm-option-edit-link medium-popup crm-hover-button" target="_blank" title="Edit Options" data-option-edit-path="civicrm/admin/options/proc_fee_20191113181638"><i class="crm-i fa-wrench"></i></a>&nbsp;

1 Answer 1


As I haven't seen your code, I can only suggest what worked for me:

function myext_civicrm_fieldOptions($entity, $field, &$options, $params) {

  if ($entity == 'Contribution') {
    if (isset($field) && $field == 'mycustomfield_123') {
      $myArray = [
        1 => 'Title 1',
        2 => 'Title 2'
      $options = $myArray;
  • Hi mate, thanks this has worked if i associate it with a field on the contrubution form but when i try to link to a custom field for e.g. custom_276_-1. Nothing happens
    – Moe
    Nov 27, 2019 at 11:55
  • @Moe try to set $field == 'custom_276'
    – VangelisP
    Nov 27, 2019 at 12:06
  • That worked! Thank you very much! I need more things to get to my end goal but this really helped.
    – Moe
    Nov 27, 2019 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.