Hi!

I'm quite new to this, so please forgive me my beginner's ignorance...

I'm currently trying to get the StaffBio module working for my Drupal 4.7.3 installation... I converted the form elements with the automated tool, and changed the return values. The settings-page seems to work fine, and the content type is displayed in the menu. But the menu entry doesn't do anything... I assume this is due to invalid form porting (everything else should work as fine in 4.7 as it did in 4.6, right?), so below are the two blocks I edited (original code commented out).

I would be really grateful if someone could tell me what I did wrong there...
Thanks in advance!

function staffbio_settings(){
	$roles = array();

	$result = db_query('SELECT rid, name FROM {role}');
	while($role = db_fetch_object($result)){
		$roles[$role->rid] = $role->name;
	}
	//$output .= form_select(t('Role to select employees from'), 'staffbio_role', variable_get('staffbio_role', 2), $roles, t('Select the role from which users for biographies should be selected.'));
	$form['staffbio_role'] = array(
	  '#type' => 'select',
	  '#title' => t('Role to select employees from'),
	  '#default_value' => variable_get('staffbio_role', 2),
	  '#options' => $roles,
	  '#description' => t('Select the role from which users for biographies should be selected.'),
	);
	//return $output;
	return $form;
}
function staffbio_form(&$node) {
	$uids = array();
	$result = db_query('SELECT u.uid, u.name FROM {users} u, {role} r, {users_roles} ur WHERE u.uid = ur.uid AND ur.rid = r.rid AND r.rid = %d ORDER BY u.name', variable_get('staffbio_role',2));
	while($f_user = db_fetch_object($result)){
	  $uids[$f_user->uid] = $f_user->name;
	}

	//$output .= form_select(t('Employee Name'), 'staffbio_uid', $node->uid, $uids, t('Select a user to associate this bio with.'));
	$form['staffbio_uid'] = array(
	  '#type' => 'select',
	  '#title' => t('Employee Name'),
	  '#default_value' => $node->uid,
	  '#options' => $uids,
	  '#description' => t('Select a user to associate this bio with.'),
	);
	//$output .= form_textarea(t('Bio'), 'body', $node->body, 60, 20, '', NULL, TRUE);
	$form['body'] = array(
	  '#type' => 'textarea',
	  '#title' => t('Bio'),
	  '#default_value' => $node->body,
	  '#cols' => 60,
	  '#rows' => 20,
	  '#description' => '',
	  '#attributes' => NULL,
	  '#required' => TRUE,
	);
	//$output .= filter_form('format', $node->format);
	// didn't know what to do with the one above...
	//return $output;
	return $form;
}

Comments

oneoftwo’s picture

I quickly looked through some other module-files yesterday and came up with changing

 --snip--
    $form['body'] = array(
--snip--
    //$output .= filter_form('format', $node->format);
    // didn't know what to do with the one above...
--snip-- 

into

 --snip--
$form['body_filter']['body'] = array(
--snip--
$form['body_filter']['format'] = filter_form($node->format);
--snip-- 

but it didn't help... I still only see the settings page and the correct "add node" menu entry, but the content type is not listed anywhere else and the menu entry doesn't do anything useful.

Thus still looking for help, thanks in advance!

csc4’s picture

I'm a newbie too, but I tried looking at the Forms API and wondered if a submit will be needed for the form? The documentation also seemed a bit unclear as to whether filter_form was depreciated in 4.7?

It would be great if we could get this working!

oneoftwo’s picture

Ok, since there was no help here, I started looking through the example nodes for 4.7 and managed to get it working. The problem actually wasn't really the form implementation (i did some things to that too, but those were more cosmetic changes), but the missing hook_node_info...

I'll try to update the module in the CVS if I can manage that somehow (never did something like that before, but we'll see). If I can't, I'll just post the new module here...

edit: ok, waiting for CVS rights...

csc4’s picture

Well done you!! I was hoping someone would chip in and help us... if you could post the new module or at least the changes I'd be very grateful!

oneoftwo’s picture

since i haven't gotten CVS rights yet, and attachements within the forums are not possible, i opened an issue for now where i attached the file right here.