I want to change some logic of function node_validate in Drupal core modules/node/node.module.

I do not want to change core source, So may I implement it in my module?

Thank you.

Comments

nevets’s picture

You can implement hook_nodeapi(), case $op equal 'validate'. The will allow you to extend validation but not directly override. What are you trying to do?

drupaul.z’s picture

Thank you very much, I will try it after lunch.

I write a module has multi pages with and buttons.

when I create my new content type node, every thing is fine.

but when I edit the created node and click back button do some change and save, there is an error occurs.
"This content has been modified by another user, changes cannot be saved."

so I want to change the logic and do not check the content type of mine.

I know this is a bad idea. there will be many rubbish records in my database.

Do you have any idea?

Thank you very much.

drupaul.z’s picture

I try hook_nodeapi, it can add some my own logic,
but I can not remove some logic in node_validate or modify them...

dman’s picture

You don't state what you want to do, so it depends.
If you want to remove something simple like 'required' or #element_validate then you could do that on hook_form_alter()

OTOH, you can also 'clear' form errors with form_set_error(NULL, NULL, TRUE) (reset)

Of course both approaches will be removing desired behavior and potentially introducing errors where the system requires some validation you want to ignore, but that's your call.

If you want to do something like auto-generate a title, and you can be sure to replace it with something, you'll probably be OK. But there may be better solutions to your actual problem than removing this error-checking.