Some times you need to bu sure that form values your computation requires are valid. Simple validation can be done by the cck basics but if you compute complex conditions that won't work. Calling form_set_error on the computed_field['code'] is simply too late to stop form handling.
I've build a simple patch to include a third code text area for validation code. This code get's evaluated at computed_field_field('validate',...). Pay attention: that does not match every call of _computed_field_compute_value().
I think that is only a minor change and should not go to another module.
Regards,
Canis Lupus
Comment | File | Size | Author |
---|---|---|---|
#3 | computed_field-414088-3-validation-code.patch | 2.25 KB | Alan D. |
#2 | computed_field.zip | 4.68 KB | mfrosch |
computed_field_validate.patch | 2.83 KB | Canis Lupus |
Comments
Comment #1
Canis Lupus CreditAttribution: Canis Lupus commentedComment #2
mfrosch CreditAttribution: mfrosch commentedHallo,
thanks lupus for your inpiration. I migrate your patch to drupal 7.15. There are just slightly differences.
And no need for the patch from line 102 till end.
Instead the following function
Attached the changed *.module.
Cheers,
Frosch
Comment #3
Alan D. CreditAttribution: Alan D. commentedStill a couple of formatting issues, but this is an untested start :)
Comment #4
k.skarlatos CreditAttribution: k.skarlatos commentedI get a WSOD when i apply this patch. I use php 5.4