function wf_crm_change_widget in Webform CiviCRM Integration 7.5
Same name and namespace in other branches
- 7.3 webform_civicrm_admin.inc \wf_crm_change_widget()
- 7.4 includes/wf_crm_admin_component.inc \wf_crm_change_widget()
Drupal FAPI submit callback Alter a webform component type.
1 string reference to 'wf_crm_change_widget'
- wf_crm_admin_component::alterForm in includes/
wf_crm_admin_component.inc - Alter back-end webform component edit forms. Called by hook_form_alter() whenever editing a webform component.
File
- includes/
wf_crm_admin_component.inc, line 723
Code
function wf_crm_change_widget($form, &$form_state) {
// Get rid of default message
unset($_SESSION['messages']['status']);
drupal_set_message(t('Click "Save component" to change this field to %type (or go back to cancel). Test your form to ensure that the new widget works with this CiviCRM field.', [
'%type' => $form['widget']['type']['#options'][$form_state['values']['widget']['type']],
]));
// Set redirect to current form with 'type' arg to trigger type change
// @see webform_civicrm_node_load
$form_state['redirect'] = [
$_GET['q'],
[
'query' => [
'type' => $form_state['values']['widget']['type'],
],
],
];
// Prevent 'destination' arg from overriding redirect
unset($_GET['destination']);
}