$cfTable.option_group_id,
$cfTable.date_format,
$cfTable.time_format,
- $cgTable.is_multiple
+ $cgTable.is_multiple,
+ og.name as option_group_name
FROM $cfTable
INNER JOIN $cgTable
- ON $cfTable.custom_group_id = $cgTable.id
+ ON $cfTable.custom_group_id = $cgTable.id
+ LEFT JOIN civicrm_option_group og
+ ON $cfTable.option_group_id = og.id
WHERE ( 1 ) ";
if (!$showAll) {
$fields[$dao->id]['date_format'] = $dao->date_format;
$fields[$dao->id]['time_format'] = $dao->time_format;
$fields[$dao->id]['is_required'] = $dao->is_required;
+ self::getOptionsForField($fields[$dao->id], $dao->option_group_name);
}
CRM_Core_BAO_Cache::setItem($fields,
return ($field['html_type'] == 'CheckBox' || strpos($field['html_type'], 'Multi') !== FALSE);
}
+ /**
+ * @param array $field
+ * @param string|null $optionGroupName
+ */
+ private static function getOptionsForField(&$field, $optionGroupName) {
+ if ($optionGroupName) {
+ $field['pseudoconstant'] = array(
+ 'optionGroupName' => $optionGroupName,
+ 'optionEditPath' => 'civicrm/admin/options/' . $optionGroupName,
+ );
+ }
+ elseif ($field['data_type'] == 'Boolean') {
+ $field['pseudoconstant'] = array(
+ 'callback' => 'CRM_Core_SelectValues::boolean',
+ );
+ }
+ elseif ($field['data_type'] == 'Country') {
+ $field['pseudoconstant'] = array(
+ 'table' => 'civicrm_country',
+ 'keyColumn' => 'id',
+ 'labelColumn' => 'name',
+ 'nameColumn' => 'iso_code',
+ );
+ }
+ elseif ($field['data_type'] == 'StateProvince') {
+ $field['pseudoconstant'] = array(
+ 'table' => 'civicrm_state_province',
+ 'keyColumn' => 'id',
+ 'labelColumn' => 'name',
+ );
+ }
+ }
+
}
'condition',
// callback funtion incase of static arrays
'callback',
+ // Path to options edit form
+ 'optionEditPath',
);
foreach ($validOptions as $pseudoOption) {
if (!empty($fieldXML->pseudoconstant->$pseudoOption)) {
$field['pseudoconstant'][$pseudoOption] = $this->value($pseudoOption, $fieldXML->pseudoconstant);
}
}
+ if (!isset($field['pseudoconstant']['optionEditPath']) && !empty($field['pseudoconstant']['optionGroupName'])) {
+ $field['pseudoconstant']['optionEditPath'] = 'civicrm/admin/options/' . $field['pseudoconstant']['optionGroupName'];
+ }
// For now, fields that have option lists that are not in the db can simply
// declare an empty pseudoconstant tag and we'll add this placeholder.
// That field's BAO::buildOptions fn will need to be responsible for generating the option list
$options = $context == 'validate' ? self::countryIsoCode() : self::country();
}
elseif ($customField->data_type === 'Boolean') {
- $options = $context == 'validate' ? array(0, 1) : array(1 => ts('Yes'), 0 => ts('No'));
+ $options = $context == 'validate' ? array(0, 1) : CRM_Core_SelectValues::boolean();
}
}
CRM_Utils_Hook::customFieldOptions($customField->id, $options, FALSE);
*/
class CRM_Core_SelectValues {
+ /**
+ * Yes/No options
+ *
+ * @return array
+ */
+ public static function boolean() {
+ return array(
+ 1 => ts('Yes'),
+ 0 => ts('No'),
+ );
+ }
+
/**
* Preferred mail format.
*
* Styles for displaying the custom data group.
*
* @return array
- *
*/
public static function customGroupStyle() {
return array(
* The status of a contact within a group.
*
* @return array
- *
*/
public static function groupContactStatus() {
return array(