You are here

function pmpapi_pull_admin_mapping_callback in Public Media Platform API Integration 7

Hide/show bundle mapping fieldset.

If no bundle is chosen, hide the related fieldset of mapping selects. If a bundle is chosen, display the mapping fieldset (for a entity given type and bundle).

#ajax callback for pmpapi_pull_admin_config()

Return value

array The mappings for the chosen bundle

See also

pmpapi_pull_admin_config()

1 string reference to 'pmpapi_pull_admin_mapping_callback'
pmpapi_pull_admin_config in pmpapi_pull/pmpapi_pull.admin.inc
Form constructor for the PMPAPI pull admin form.

File

pmpapi_pull/pmpapi_pull.admin.inc, line 139
Basic admin forms, validators, and submit handlers.

Code

function pmpapi_pull_admin_mapping_callback($form, $form_state) {
  if (!empty($form_state['triggering_element']['#ajax']['pmpapi_pull_entity_type']) && !empty($form_state['triggering_element']['#ajax']['pmpapi_pull_bundle_name'])) {
    $entity_type = $form_state['triggering_element']['#ajax']['pmpapi_pull_entity_type'];
    $bundle_name = $form_state['triggering_element']['#ajax']['pmpapi_pull_bundle_name'];
    if ($form_state['triggering_element']['#value'] == '0') {
      $form[$entity_type][$bundle_name . '_settings'][$bundle_name . '_mappings']['#attributes']['class'][] = 'element-invisible';
    }
    else {
      $form[$entity_type][$bundle_name . '_settings'][$bundle_name . '_mappings']['#attributes']['class'] = NULL;
    }
    return $form[$entity_type][$bundle_name . '_settings'][$bundle_name . '_mappings'];
  }
}