*/
public function preProcess() {
parent::preProcess();
- $this->assign('selectedChild', 'settings');
+ $this->setSelectedChild('settings');
- if ($this->_id) {
- $this->assign('entityID', $this->_id);
+ $entityID = $this->_id ?: $this->_templateId;
+ if ($entityID) {
+ $this->assign('entityID', $entityID);
$eventType = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
- $this->_id,
+ $entityID,
'event_type_id'
);
}
$this->set('type', 'Event');
$this->set('subType', CRM_Utils_Array::value('event_type_id', $_POST));
$this->assign('customDataSubType', CRM_Utils_Array::value('event_type_id', $_POST));
- $this->set('entityId', $this->_id);
+ $this->set('entityId', $entityID);
- CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_eventType, 1, 'Event', $this->_id);
+ CRM_Custom_Form_CustomData::preProcess($this, NULL, $this->_eventType, 1, 'Event', $entityID);
CRM_Custom_Form_CustomData::buildQuickForm($this);
CRM_Custom_Form_CustomData::setDefaultValues($this);
}
if ($this->_eventType) {
$this->assign('customDataSubType', $this->_eventType);
}
- $this->assign('entityId', $this->_id);
$this->_first = TRUE;
$this->applyFilter('__ALL__', 'trim');
* Process the form submission.
*/
public function postProcess() {
- $params = $this->controller->exportValues($this->_name);
+ $params = array_merge($this->controller->exportValues($this->_name), $this->_submitValues);
//format params
$params['start_date'] = CRM_Utils_Array::value('start_date', $params);
$params['default_role_id'] = CRM_Utils_Array::value('default_role_id', $params, FALSE);
$params['id'] = $this->_id;
- $customFields = CRM_Core_BAO_CustomField::getFields('Event', FALSE, FALSE,
- CRM_Utils_Array::value('event_type_id', $params)
- );
- $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
- $this->_id,
- 'Event'
- );
-
//merge params with defaults from templates
if (!empty($params['template_id'])) {
$params = array_merge(CRM_Event_BAO_Event::getTemplateDefaultValues($params['template_id']), $params);
+ foreach ($params as $key => $value) {
+ $customFieldInfo = CRM_Core_BAO_CustomField::getKeyID($key, TRUE);
+ if (!empty($customFieldInfo[1])) {
+ $params[str_replace($customFieldInfo[1], '-' . $customFieldInfo[1], $key)] = $value;
+ unset($params[$key]);
+ }
+ }
}
+ $params['custom'] = CRM_Core_BAO_CustomField::postProcess($params,
+ $this->_id,
+ 'Event'
+ );
+
// now that we have the event’s id, do some more template-based stuff
if (!empty($params['template_id'])) {
$event = CRM_Event_BAO_Event::copy($params['template_id'], $params);