$genders = CRM_Core_PseudoConstant::get('CRM_Contact_BAO_Contact', 'gender_id'); foreach ($genders as $id => $value) { echo "Gender ID: " . $id . ", Value: " . $value . "\n"; }
$fieldOptions = array(); $fieldOptions['1'] = 'Option 1'; $fieldOptions['2'] = 'Option 2'; $fieldOptions['3'] = 'Option 3'; CRM_Core_Form::addMultiSelect($form, 'field_name', 'Label', $fieldOptions);This code sets the values for a select field in a form. The addMultiSelect() function from the CRM_Core_Form class is used to add the field to the form and the $fieldOptions array is used to define the options. In conclusion, CRM_Core_PseudoConstant is a useful package library that simplifies the management of constants in the CRM software by providing an easy to use API for accessing and manipulating them. These code examples demonstrate some of the many ways the PseudoConstant class can be used in a PHP application.