Hi,
I know my module is putting the correct data into the table I have setup for it...I checked the mysql database and all the data I enter when creating a node with my module gets stored.
However, when I go to view or edit the node, I can't see any of the data in the fields.
Could someone please help me figure out what I need to do? I've tried to figure it out myself, but I didn't get any further.

Here is my module code:


/**
 * @file
 * Enables users to submit space share tasks.
 */

/**
 * Implementation of hook_help().
 */
function sstask_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('Enables the creation of spaceshare tasks.');
    case 'node/add#sstask':
      return t('Create a spaceshare task.');
  }
}

/**
 * Implementation of hook_node_name().
 */
function sstask_node_name($node) {
  return t('spaceshare task');
}

/**
 * Implementation of hook_perm().
 */
function sstask_perm() {
  return array('create spaceshare tasks', 'edit own spaceshare tasks');
}

/**
 * Implementation of hook_access().
 */
function sstask_access($op, $node) {
  global $user;

  if ($op == 'create') {
    return user_access('create spaceshare tasks');
  }

  if ($op == 'update' || $op == 'delete') {
    if (user_access('edit own spaceshare tasks') && ($user->uid == $node->uid)) {
      return TRUE;
    }
  }
}

/**
 * Implementation of hook_menu().
 */
function sstask_menu($may_cache) {
  $items = array();

  if ($may_cache) {
    $items[] = array('path' => 'node/add/sstask', 'title' => t('spaceshare task'),'access' => user_access('create spaceshare tasks'));
    //$items[] = array('path' => 'sstask','title' => t('spaceshare tasks'),'callback' => '_sstasks_main','access' => user_access('access spaceshare tasks main page'),'type' => MENU_CALLBACK);
  }

  return $items;
}

/**
 * Implementation of hook_form().
 */
function sstask_form(&$node) {
  $output = '';

  if (function_exists('taxonomy_node_form')) {
    $output .= implode('', taxonomy_node_form('sstask', $node));
  }
  
  //THESE ARE THE NODE ELEMENTS FOR USER INPUT SPECIFIC TO SPACESHARE TASK!!!
  $output .= form_textfield(t('Task start date'), 'startdate', $node->startdate, 60, 10, 'must be of the format mm/dd/yyyy', NULL, TRUE);
  $output .= form_textfield(t('Task end date'), 'enddate', $node->enddate, 60, 10,'must be of the format mm/dd/yyyy',NULL, TRUE);

  $arrOptions = array('please select a team' => t('team 1'));
  $output .= form_select(t('Associated team'), 'taskteam', 'please select a team', $arrOptions, 'please select the team this task is associated with');
  
  $output .= form_textarea(t('Task description'), 'taskdescription', $node->taskdescription, 60, 20, 'Describe what must be done to complete this task', NULL, TRUE);
  
  return $output;
}

/**
 * Implementation of hook_insert().
 */
function sstask_insert($node) {
  db_query("INSERT INTO {sstask} (nid, startdate, enddate, taskteam, taskdescription) VALUES (%d, '%s', '%s', '%s', '%s')", $node->nid, $node->startdate, $node->enddate, $node->taskteam, $node->taskdescription);
}

/**
 * Implementation of hook_view().
 */
function sstask_view(&$node, $teaser = FALSE, $page = FALSE) {
  $node->body .= $node->taskdescription;
}//does this produce any output?

Comments

nevets’s picture

You need to implement the load hook which is used to load your modules data and the update hook which is used when and existing node is saved.

DriesK’s picture

and implementing hook_delete will keep your database clean :-)

SamuraiDave’s picture

You got married recenty, didn't you? Congratulations :) (If I am correct)
Thanks very much for the help! :)

DriesK’s picture

dries got married recently. He is the founder and lead developer of Drupal. I'm just a simple module developer... People are often confused by our names, I should have chosen another one to start with, but when I realised it, it was too late to change it.

But, glad I could help anyway :-)