/**
  * Get options for a given contact field.
  *
  * @see CRM_Core_DAO::buildOptions
  *
  * TODO: Should we always assume chainselect? What fn should be responsible for controlling that flow?
  * TODO: In context of chainselect, what to return if e.g. a country has no states?
  *
  * @param string $fieldName
  * @param string $context
  * @see CRM_Core_DAO::buildOptionsContext
  * @param array $props
  *   whatever is known about this dao object.
  *
  * @return array|bool
  */
 public static function buildOptions($fieldName, $context = NULL, $props = array())
 {
     $params = array();
     // Special logic for fields whose options depend on context or properties
     switch ($fieldName) {
         case 'contact_sub_type':
             if (!empty($props['contact_type'])) {
                 $params['condition'] = "parent_id = (SELECT id FROM civicrm_contact_type WHERE name='{$props['contact_type']}')";
             }
             break;
         case 'contact_type':
             if ($context == 'search') {
                 // CRM-15495 - EntityRef filters and basic search forms expect this format
                 // FIXME: Search builder does not
                 return CRM_Contact_BAO_ContactType::getSelectElements();
             }
             break;
             // The contact api supports some related entities so we'll honor that by fetching their options
         // The contact api supports some related entities so we'll honor that by fetching their options
         case 'group_id':
         case 'group':
             return CRM_Contact_BAO_GroupContact::buildOptions('group_id', $context, $props);
         case 'tag_id':
         case 'tag':
             $props['entity_table'] = 'civicrm_contact';
             return CRM_Core_BAO_EntityTag::buildOptions('tag_id', $context, $props);
     }
     return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
 }