You are here

function _noderelationships_child_node_form_pre_render in Node Relationships 6

Pre-render handler for child node form.

1 call to _noderelationships_child_node_form_pre_render()
_noderelationships_child_node_form_pre_render_proxy in ./noderelationships.module
Proxy function to invoke the pre_render callback for the child node form.

File

./noderelationships.pages.inc, line 737
Implementation of user land pages.

Code

function _noderelationships_child_node_form_pre_render($form) {
  static $ready;

  // Be carefull because the node edit form is rendered by theme_node_form(),
  // and theme_node_form() executes drupal_render($form) again, so we're
  // invoked twice. The first time by drupal_render_form(), and the second
  // time by theme_node_form().
  if (!isset($ready)) {
    $ready = TRUE;

    // Send stylesheets and javascript to the page.
    $module_path = drupal_get_path('module', 'noderelationships');
    drupal_add_css($module_path . '/css/noderelationships.noderef_dialog.css');
    drupal_add_js($module_path . '/js/noderef_dialog.js');

    // Wrap the form into our own container.
    $prefix = '';
    if (!empty($form['#noderelationships_child'])) {
      $referrer_type = $form['#noderelationships_child']['referrer_type'];
      $field_name = $form['#noderelationships_child']['field_name'];

      // Render tabs when 'Search and reference' option is also enabled.
      $noderef_settings = noderelationships_settings_load($referrer_type, 'noderef');
      if (isset($noderef_settings['search_and_reference_view'][$field_name])) {
        $prefix = theme('noderelationships_noderef_page_tabs', 'create', $referrer_type, $field_name);
      }
    }
    $prefix .= theme('noderelationships_noderef_page_prefix');
    $suffix = theme('noderelationships_noderef_page_suffix');
    $form['#prefix'] = $prefix . (!empty($form['#prefix']) ? $form['#prefix'] : '');
    $form['#suffix'] = (!empty($form['#suffix']) ? $form['#suffix'] : '') . $suffix;
  }
  return $form;
}