Allow contributions be assigned to a configured campaign per profile.
This commit is contained in:
parent
336870c38e
commit
5ce76eae5f
4 changed files with 38 additions and 1 deletions
|
@ -200,6 +200,15 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
array('class' => 'crm-select2 huge', 'multiple' => 'multiple')
|
||||
);
|
||||
|
||||
$this->add(
|
||||
'select', // field type
|
||||
'campaign', // field name
|
||||
E::ts('Assign donation to campaign'), // field label
|
||||
$this->getCampaigns(), // list of options
|
||||
FALSE, // is not required
|
||||
array('class' => 'crm-select2 huge')
|
||||
);
|
||||
|
||||
$this->addButtons(array(
|
||||
array(
|
||||
'type' => 'submit',
|
||||
|
@ -470,4 +479,22 @@ class CRM_Twingle_Form_Profile extends CRM_Core_Form {
|
|||
return $this->getGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves campaigns as options for select elements.
|
||||
*/
|
||||
public function getCampaigns() {
|
||||
$campaigns = array();
|
||||
$query = civicrm_api3('Campaign', 'get', array(
|
||||
'option.limit' => 0,
|
||||
'return' => array(
|
||||
'id',
|
||||
'title',
|
||||
)
|
||||
));
|
||||
foreach ($query['values'] as $campaign) {
|
||||
$campaigns[$campaign['id']] = $campaign['title'];
|
||||
}
|
||||
return $campaigns;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue