Closed (fixed)
Project:
ImageCache
Version:
6.x-2.0-beta1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
8 Oct 2008 at 07:17 UTC
Updated:
29 Oct 2008 at 23:17 UTC
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.
| Comment | File | Size | Author |
|---|---|---|---|
| imagecache_validate_subactions.patch | 753 bytes | dman |
Comments
Comment #1
drewish commentedi 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.
Comment #2
dman commentedYou 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.