[development] modify $node->something from hook_nodeapi
Fabio Varesano
fabio.varesano at gmail.com
Sun Jun 11 09:07:11 UTC 2006
Hi everybody,
I have a module which create nodes of type "mytype" which has a field
called "something" accessible from $node->something.
I'm working on another module (mytype_change.module) which need to
modify one of the "mytype.module" field.
I want to change the "something" field of the just submitted node to
something different that the user input.
If the user insert 'foo' as value of the something field I want that
my mytype_change.module can change the value to 'bar' just before the
node insertion on database.
So while the user thinks that he inserted 'foo' as value of the
something field instead the system has registered 'bar' into the database.
I'm doing this through the hook_nodeapi where $op param is 'validate'.
then I do something like:
function mytype_change_nodeapi(&$node, $op, $teaser) {
switch ($op) {
case 'validate':
if($node->something == 'foo')
$node->something = 'bar';
break;
}
}
But the code above does not work.
The something value is always 'foo' even if I submit or preview the node.
Can someone point me to the right direction???
Thank you.
Fabio Varesano
More information about the development
mailing list