[#14] implementing individual prefix mapping
This commit is contained in:
parent
48116e5c98
commit
24801bb6bc
4 changed files with 75 additions and 7 deletions
|
@ -90,6 +90,14 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
*/
|
||||
protected static $_genderOptions = NULL;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
* A static cache of retrieved prefixes found within
|
||||
* static::getGenderOptions().
|
||||
*/
|
||||
protected static $_prefixOptions = NULL;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*
|
||||
|
@ -267,6 +275,28 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
TRUE
|
||||
);
|
||||
|
||||
$this->add(
|
||||
'select',
|
||||
'prefix_male',
|
||||
E::ts('Prefix option for submitted value "male"'),
|
||||
static::getPrefixOptions(),
|
||||
FALSE
|
||||
);
|
||||
$this->add(
|
||||
'select',
|
||||
'prefix_female',
|
||||
E::ts('Prefix option for submitted value "female"'),
|
||||
static::getPrefixOptions(),
|
||||
FALSE
|
||||
);
|
||||
$this->add(
|
||||
'select',
|
||||
'prefix_other',
|
||||
E::ts('Prefix option for submitted value "other"'),
|
||||
static::getPrefixOptions(),
|
||||
FALSE
|
||||
);
|
||||
|
||||
$payment_instruments = CRM_Twingle_Profile::paymentInstruments();
|
||||
$this->assign('payment_instruments', $payment_instruments);
|
||||
foreach ($payment_instruments as $pi_name => $pi_label) {
|
||||
|
@ -593,7 +623,7 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves campaigns present within the system as options for select form
|
||||
* Retrieves genders present within the system as options for select form
|
||||
* elements.
|
||||
*
|
||||
* @return array
|
||||
|
@ -619,6 +649,33 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
return static::$_genderOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves prefixes present within the system as options for select form
|
||||
* elements.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
public static function getPrefixOptions() {
|
||||
if (!isset(static::$_prefixOptions)) {
|
||||
static::$_prefixOptions = array('' => E::ts('none'));
|
||||
$query = civicrm_api3('OptionValue', 'get', array(
|
||||
'option.limit' => 0,
|
||||
'option_group_id' => 'individual_prefix',
|
||||
'is_active' => 1,
|
||||
'return' => array(
|
||||
'value',
|
||||
'label',
|
||||
),
|
||||
));
|
||||
foreach ($query['values'] as $prefix) {
|
||||
static::$_prefixOptions[$prefix['value']] = $prefix['label'];
|
||||
}
|
||||
}
|
||||
return static::$_prefixOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves CiviSEPA creditors as options for select form elements.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue