You are here

function slickgrid_node_form_pre_render in Slickgrid 6

1 string reference to 'slickgrid_node_form_pre_render'
slickgrid_form_alter in ./slickgrid.module
Implementation of hook_form_alter().

File

./slickgrid.module, line 836

Code

function slickgrid_node_form_pre_render(&$form, &$form_state) {
  if ($_POST['vid']) {
    $vid = $_POST['vid'];

    // Load the vocabulary so we know whether this vocabulary uses tags
    $vocabularies = taxonomy_get_vocabularies($form['#node']->type);
    if ($vocabularies[$vid]->tags) {
      $form['#field_name'] = 'taxonomy[tags][' . $vid . ']';
    }
    else {
      $form['#field_name'] = 'taxonomy[' . $vid . ']';
    }
  }
  elseif ($_POST['field_name'] == 'group_nid') {
    $form['#field_name'] = 'og_groups';
  }
  elseif ($_POST['field_name'] == 'body') {
    $form['#field_name'] = 'body_field';
  }
  else {
    $form['#field_name'] = $_POST['field_name'];
  }

  // Some modules might need to play around with the form / field name to get the correct part of the form
  drupal_alter('slickgrid_field', $form, $form['#field_name']);
  if (!slickgrid_callback_get_form_element($form, $form['#field_name'])) {
    drupal_set_message(t('Field not found'), 'error');
  }
  return $form;
}