Hi everybody!

I'm new in Drupal, i've started 2 weeks ago managing this CMS and i've solved every problem
that appeared but now i'm in trouble. My situation is that i created a module that shows a
form in which you can write a title (is a drupal default field), name, description, length and latitude
(these are fields from my hook_schema).
The problem is that when i try to edit from the option in 'Administer/Content Management/Content'
the title appears with its value but the fields that i'd created appear empty. Is there any hook to
control this? Any idea to solve it?

Thanks!!

Comments

sl_hemanth’s picture

hi ,

First you check your module storing the node values in database or not.If not storing please check your code.

hemanth

jesusDrupal’s picture

hi hemanth,

Thanks for the answer. I've checked my database and i've perfectly stored the data corresponding
to each node i've created with my content type. Now, i've 6 rows in my 'drup_pois' table. And in the
'drup_node' table is also the reference to this content. My problem is that data doesn't load when i
click in the edit tab, only the title field (that is a Drupal default field, i think).

If you have any idea.......

jesus

alim418’s picture

you will have to first use $op = 'load' in hook_nodeapi() http://api.drupal.org/api/function/hook_nodeapi/6 to load your custom data into the node

Then you can use hook_form_alter() http://api.drupal.org/api/function/hook_form_alter/6 to load the value into your custom fields $from['custom_fiels']['#default_value'] = $form['#node']['custom_field_value']

jesusDrupal’s picture

hi alx0418!!

Thanks, i'll try to solve it in your way. I'd read about hook_node api but i didn't understand it.
Thanks for the api references you have included. When i get a result i'll post again to tell you.

Thanks a lot!!!!

jesusDrupal’s picture

hi again alx0418,

I've been trying to do what you adviced to me but i'm lost in my problem, i'm still loading
the fields in blank in the Edit tab. Here i show you my code about the hook_nodeapi and the
hook_form_alter:

function pois_nodeapi(&$node, $op = 'load'){
switch($op){
case 'load':
$valores = array(
'nombre' => $node->nombre,
'longitud' => $node->longitud,
'latitud' => $node->latitud,
);
return $valores;
break;
}
}

function pois_form_alter(&$form, $form_state, $form_id){
$form['nombre']['#default_value'] = $form['#node'][$node->nombre];
$form['longitud']['#default_value'] = $form['#node'][$node->longitud];
$form['latitud']['#default_value'] = $form['#node'][$node->latitud];
}

I know i'm making a lot of mistakes because of mi inexperience with Drupal.
Thanks about all the help you can give me........

alim418’s picture

Sorry use 'prepare' instead of 'load', use load when you want to load extra data in to $node object

<?php
function pois_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
   switch($op){
		case 'prepare':
		  if ($node->type =='pois') {
		  	$node->nombre = 'nombre';
		  	$node->longitud = 'longitud';
		  	$node->latitud = 'latitud';
		  }
		break;
	}
}

function pois_form_alter(&$form, $form_state, $form_id){
 if($form_id=='yourform_id') {
   $form['nombre']['#default_value'] = $form['#node']->nombre;
   $form['longitud']['#default_value'] = $form['#node']->longitud;
   $form['latitud']['#default_value'] = $form['#node']->latitud;
  }
}
?>
jesusDrupal’s picture

hi alx0418,

I did what you told me and it worked.
Thanks for teach me about these functions.

See you in other problem (perhaps)...