I need to add one more button to an event form but right now when I use
addButtons
it overrides existing buttons How can I make sure the buttons which I add are updated instead of replacing the existing ones?
function custom_changes_civicrm_buildForm($formName, &$form){
if($formName == 'CRM_Event_Form_ManageEvent_EventInfo' && $user->uid){
$buttons = array(
array(
'type' => 'upload',
'name' => ts('Request for Approval'),
'isDefault' => TRUE,
),
);
$form->addButtons($buttons);
}
}
In the CRM\Event\Form\ManageEvent.php
I see there are protected variables, which I am unable to add it in the conditions inside hook_buildForm
e.g. _cancelURL, _single , so how can I override it using hook_buildForm , an
example would be helpful.
/**
* Build the form object.
*/
public function buildQuickForm() {
$session = CRM_Core_Session::singleton();
$this->_cancelURL = CRM_Utils_Array::value('cancelURL', $_POST);
if (!$this->_cancelURL) {
if ($this->_isTemplate) {
$this->_cancelURL = CRM_Utils_System::url('civicrm/admin/eventTemplate',
'reset=1'
);
}
else {
$this->_cancelURL = CRM_Utils_System::url('civicrm/event/manage',
'reset=1'
);
}
}
if ($this->_cancelURL) {
$this->addElement('hidden', 'cancelURL', $this->_cancelURL);
}
if ($this->_single) {
$buttons = array(
array(
'type' => 'upload',
'name' => ts('Save'),
'isDefault' => TRUE,
),
array(
'type' => 'upload',
'name' => ts('Save and Done'),
'spacing' => ' ',
'subName' => 'done',
),
array(
'type' => 'cancel',
'name' => ts('Cancel'),
),
);
$this->addButtons($buttons);
}
else {
$buttons = array();
if (!$this->_first) {
$buttons[] = array(
'type' => 'back',
'name' => ts('Previous'),
'spacing' => ' ',
);
}
$buttons[] = array(
'type' => 'upload',
'name' => ts('Continue'),
'spacing' => ' ',
'isDefault' => TRUE,
);
$buttons[] = array(
'type' => 'cancel',
'name' => ts('Cancel'),
);
$this->addButtons($buttons);
}
$session->replaceUserContext($this->_cancelURL);
$this->add('hidden', 'is_template', $this->_isTemplate);
}