Hello,
I've made a module that adds a form to the Book edit page which allows me to change the content type to uneditable (lock the page) or bpage (unlock the page). I have 2 content types, 1 is bpage other is uneditable, uneditable is editable only by moderators, bpage is editable by everyone. The change is done by editing the node type from mysql.
I've added a #element_validate to the form so that the function that changes the mysql is called after the form is submitted. The module works well if i make the validate function use form_set_error, if i don't, it's like the function never gets run.
This is part of the code (i think you'll be able to spot the problem from here, if not, check the entire code after this):
<?php
// above this $form['changer'] is defined (radios type form)
$form['changer']['#element_validate'] = array('changer_validate');
}
// this is the function that gets called after submit
function changer_validate($form, &$form_state) {
// if i uncomment the line below the module works as wanted
// form_set_error('error', t('error'));
$changer_response = $form_state['values']['radios'];
if (arg(0) == 'node' && is_numeric(arg(1))) $nodeid = arg(1);
if($changer_response == "0")
{
db_query("UPDATE `drupal`.`node` SET `type` = 'uneditable' WHERE `node`.`nid` = $nodeid");
}
else if($changer_response == "1")