I'm working with a custom module that is a re-write of poll module for Drupal 5 to allow the dynamic addition of fields on a node input form. Currently the new fields are generated on preview. However, I've run into a situation where validation will get in the way of adding field to this form on the fly. It's not necessary to validate on preview, only submit. Is there a way to skip validation during preview?

Another way to do this might be some kind of AJAX solution but it's Drupal 5 and we don't have time to develop a new solution. We need to work with what we have if possible.

NOTE: This: http://drupal.org/node/370537 is the kind of issue I'm dealing with, although in 5 not 7. I've looked this code over and I don't think it will be usable. There are too many D6/7 things like $form_state that are not available in 5. Any suggestions for 5?

Comments

mjlF95’s picture

I managed to come up with my own solution to this. It's posted in http://drupal.org/node/370537 but I'll put it here too.

I set a flag (in the form of a hidden form item) to one state at the beginning of the form function to "invalid". Then I use my own node_form_add_preview function that sets this flag to "valid" before running drupal_validate_form. In the validation function I have a conditional that sets the error message only if this flag = "invalid". Therefore it only runs on submit, not on preview. This does not work for items that have "#required" set but it works for stuff specified in the validate function and that's all I need.

mdupont’s picture

Hello,

There is also the Skip Validation module that allows to do that.