You are here

function slickgrid_callback_get_form in Slickgrid 6

Callback function - retrieve a form

File

./slickgrid.callbacks.inc, line 191

Code

function slickgrid_callback_get_form() {
  module_load_include('inc', 'node', 'node.pages');
  $node = node_load($_POST['nid']);
  if (node_access('update', $node)) {
    $html = drupal_get_form($node->type . '_node_form', $node);
    $data = new stdClass();
    $data->content = $html;

    // Register the JavaScript callback for this module.
    $data->__callbacks = array();

    // Allow other modules to extend the data returned.
    drupal_alter('ajax_data', $data, 'slickgrid', $html);
    return array(
      'data' => $data,
    );
  }
  else {
    drupal_set_message(t("You do not have access to edit @title", array(
      '@title' => $node->title,
    )), 'error');
  }
}