You are here

Hacks for includes/form.inc in Node import 6

The problem node_import has by design - where the design is that we want to use the normal form validation - is that when a form is submitted more then once, the validation of the form is not done correctly by the core includes/form.inc

This file tries to lift this limitation. The solution is based (or rather copied) from sites/all/modules/views/includes/form.inc of the views module which needs to do the same crappy stuff (and even more).

Short explanation: instead of


  drupal_execute($form_id, $form_state, ...);

use


  node_import_drupal_execute($form_id, $form_state, ...);

whenever the form you want to execute can be executed more than once in the same page request.

For the core bug, see http://drupal.org/node/260934 : Static caching: cannot call drupal_validate_form on the same form more than once.

Note that another bug for multiple form validation and submission (one that could not be lifted) was fixed in Drupal 6.5, see http://drupal.org/node/180063 : No way to flush form errors during iterative programatic form submission.

Many, many thanks to merlinofchaos!!

File

./node_import.inc, line 2012
Public API of the Node import module.

Functions

Namesort descending Location Description
node_import_drupal_execute ./node_import.inc The original version of drupal_execute() calls drupal_process_form(). The modified version sets $form_state['must_validate'] = TRUE and calls node_import_drupal_process_form() instead.
node_import_drupal_process_form ./node_import.inc The original version of drupal_process_form() calls drupal_validate_form(). The modified version calls node_import_drupal_validate_form() instead.
node_import_drupal_validate_form ./node_import.inc The original version of drupal_validate_form() keeps a static array of validated forms. The modified version checks $form_state['must_validate'] to see if the form needs validation. If set and TRUE, validation is forced even if it was…