Installing validators when installing another module

Gary Feldman - June 29, 2009 - 22:21
Project:Validation API
Version:6.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

If I understand the current mechanism correctly, in order to have my module install validators, the supported approach is to write a hook which will then be called by visiting the import tab.

That's more work than should be needed to install a module, plus it will be error prone. There's no guarantee that the person installing the module on a site will actually do the validator import.

It strikes me that it would be easy to factor out the bulk of validation_api_admin_import_form_submit into a new function, so that it would just be

function validation_api_admin_import_form_submit($form, &$form_state) {
  // Run the given, and set it up to be in a valid state.
  $validators = eval($form_state['values']['code']);
  validation_api_admin_import_array($validators);
}

and then the new function validation_api_admin_import_array would contain the rest of the original validation_api_admin_import_form_submit function. Instead of writing a hook-style function, my module_install function could just call validation_api_admin_import_array directly.

#1

Gary Feldman - June 29, 2009 - 22:26

On second look, maybe all that's needed is to rename _validation_api_import to be a published function. I think validation_api_admin_import_form_submit just deals with stuff from the form processing before passing it on.

 
 

Drupal is a registered trademark of Dries Buytaert.