i am trying to save form state in database and want to view in a listing page with its error validation.

i.e, i want to validate a previously saved form state from my database.

this is a node type form .

i had already tried node_validate its not working because i fetch the data before submitting the node . so there is no nid and for that it is not working

and also tried drupal_validate_form but it is showing

[form_token] => The form has become outdated. Copy any unsaved work in the form below and then reload this page

Any help is most Appreciable.


Can any one just say How To save my form and retrieve it from database and load all result in a page .

1 Answer 1


This may not quite answer your question, but I think it might help with whatever you're trying to do.

You can alter the node creation form to have extra validation and display it on the screen using the devel module, along with a custom module that calls hook_form_alter

function mymodule_form_alter(&$form, &$form_state){
    //add a function in #validate to read form_state and show it on screen
    $form[#validate][] = mymodule_read_values($form_state);
    //or if you want to make it happen before any of the other form validation, uncomment the next line and comment the one above
    //array_unshift($form[#validate], mymodule_read_values($form_state));

function mymodule_read_values(&$form_state){
    // make sure you have devel module installed or this will cause WSOD
    // if you want to prevent form submission you can uncomment the next line
    // throw new Exception('Cancelling form submit - see mymodule');

Remember of course, to replace any instance of 'mymodule' with the name of your module, particularly the first one, or the hook won't work.

Doing this will show the structure of the form_state on the screen when you try to save the node.

If you want to target a specific form you can change the first line to

function mymodule_form_FORMID_GOES_HERE_alter(&$form, &$form_state){
  • i already store my form state in db i want to validate the form state manually on retrieved data
    – Lucifer
    Commented Sep 4, 2014 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.