It was possible in D5, but in D6 the new FAPI seems to make it harder for sub-forms (in this case imagecache_action actions) to 'validate' the submission.
I need my imagecache_actions - eg my text2canvas - to ensure that the font file exists before an action is saved.

I'm trying to get the validation to fire using a line in imagecache that shunts the subforms validate callback up into the parent form. D7 has fixed this problem, allowing subforms to validate themselves but it appears D6 doesn't. Unless there's another trick I don't know.

@@ -439,6 +455,9 @@ function imagecache_ui_action_form($form
     require_once($definitions[$action['action']]['file']);
   }
   $form['data'] = call_user_func($action['action'] .'_form', $action['data']);
+  if (isset($form['data']['#validate'])) {
+    $form['#validate'] = $form['data']['#validate'];
+  }
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Update Action'),

Patch attached BUT the line numbers may be a little off, pending another path I'm testing, so it may not apply clean.

CommentFileSizeAuthor
imagecache_validate_subactions.patch753 bytesdman

Comments

drewish’s picture

Status: Needs review » Closed (won't fix)

i think you just need to be using element level validation: http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...

feel free to re-open if you don't think that'll meet your needs.

dman’s picture

Status: Closed (won't fix) » Closed (fixed)

You are probably right. I thought it should have been possible in D6, and tried a heap but it wasn't triggering.
I was trying to use #validate, I hadn't seen it was renamed to #element_validate.
Thanks, I'll look at that.