You are here

function wf_crm_change_widget in Webform CiviCRM Integration 7.4

Same name and namespace in other branches
  1. 7.5 includes/wf_crm_admin_component.inc \wf_crm_change_widget()
  2. 7.3 webform_civicrm_admin.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.', array(
    '%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'] = array(
    $_GET['q'],
    array(
      'query' => array(
        'type' => $form_state['values']['widget']['type'],
      ),
    ),
  );

  // Prevent 'destination' arg from overriding redirect
  unset($_GET['destination']);
}