Exemplo n.º 1
0
 /**
  * @param string $context
  * @return array|bool
  */
 public function getOptions($context = NULL)
 {
     CRM_Core_DAO::buildOptionsContext($context);
     if (!$this->id) {
         return FALSE;
     }
     if (!$this->data_type || !$this->custom_group_id) {
         $this->find(TRUE);
     }
     if (!empty($this->option_group_id)) {
         $options = CRM_Core_OptionGroup::valuesByID($this->option_group_id, FALSE, FALSE, FALSE, 'label', !($context == 'validate' || $context == 'get'));
     } elseif ($this->data_type === 'StateProvince') {
         $options = CRM_Core_Pseudoconstant::stateProvince();
     } elseif ($this->data_type === 'Country') {
         $options = $context == 'validate' ? CRM_Core_Pseudoconstant::countryIsoCode() : CRM_Core_Pseudoconstant::country();
     } elseif ($this->data_type === 'Boolean') {
         $options = $context == 'validate' ? array(0, 1) : CRM_Core_SelectValues::boolean();
     } else {
         return FALSE;
     }
     CRM_Utils_Hook::customFieldOptions($this->id, $options, FALSE);
     CRM_Utils_Hook::fieldOptions($this->getEntity(), "custom_{$this->id}", $options, array('context' => $context));
     return $options;
 }