I've read several custom module tutorials but none seem to show how to edit a record. My module does not use node but has a custom table. So, I think I ought to be able to drupal_get_form and populate the #value with the fields. But to set up the menu to get the parameter in the URL and my page callback is not working.
Looking around I found this answer and modeled the below after it but I get a default page instead of my expected form.
$items['redashboard/project/%/edit'] = array(
'title' => (t('Edit project')),
'page callback' => 'drupal_get_form',
'page arguments' => array('re_dashboard_edit_project_form', 2),
'access callback' => TRUE,
);
function re_dashboard_edit_project_form($form, $form_state, $projectid) {
$project = pull_project($projectid);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Research Project Name/Question'),
'#value' => $project->projectName,
'#required' => TRUE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Create',
);
return $form;
}
function pull_project($projectid) {
$query = db_select('Projects', 'p');
$query->fields('p', array('ProjectID', 'residentID', 'projectName', 'projectMentor', 'projectStatus', 'citation', 'lastUpdated'));
$query->condition('ProjectID', $projectid);
$result = $query->execute();
return $result->fetch();
}
So, how should I set up a page to edit this record if not this way? Or to the point how should I set up the menu so that this callback gets rendered? thx, sam