By derhasi on
I tried to create a Module as CCK Field, that provides functionality to add custom validation code to any node-type via cck.
http://www.derhasi.de/cck_validation
http://www.derhasi.de/system/files/cck_validation.module
http://www.derhasi.de/system/files/cck_validation.info
When creating the Field, behaviour seems to be correct. But when I try to edit the content-field, there are two Errors.
- After submitting configuration the form_set_error set in the validation code, is called. It seems that
hook_field($op=validation)is called. So changed field settings cannot be saved. - After pressing on the Configuration submit button, the error "The default value is invalid." appears.
Can anyone help me with these problems?
Comments
...
There's a 'default value' box on the settings form, which doesn't make sense in your case (to see what I'm talking about, create a number/text/options field and see the 'default value' box). You can use the 'callbacks' field $op to tell CCK not to provide this 'default value' entry.
Thank you!
Thank you!
I solved the problem by adding:
to
cck_validation_widget_settings(). I think that's what you meant.Now the custom Form_set_error-Message at configuration page did disappear too. I don't have a clue why, but it works!
First working Version
First working Version available. Feel invited to test it and leave your comments.
http://www.derhasi.de/cck_validation
JavaScript Validation & Drupal.org Project
Two things:
1) Can we add a field to enter custom validation via JavaScript, to avoid a trip to server
2) Can we create a project on Drupal.org to have proper development & issue queue ?
1) Can we add a field to
Unfortunatley I don't have any knowledge in JavaScript. But if you are able to do so, sure we can extend the module.
I don't have any experience with creating a project, cvs and so on. But this will be the best way to extend the modules features. Though due to lack of time, I cannot assure propper support.
CCK Validation is now
CCK Validation is now available as Drupal Contribution/Project on http://drupal.org/project/cck_validation
I still fight to create the first release version there, but haven't been successfull till now. :/
great module
Thank you for this great module... It's a must to validate CCK fields. Excuse my ignorance, but I would like to know what the field and widget options are for? and how different the behaivior would be with each option?
Cheers!
The difference of field and
The difference of field and widget is the format of the variables you get. Especially in Fields like Date this does matter. While Widget-validation proofs on the Input format, field validation will proof on the storage format.
for example Date-Field:
widget: Array of (day, month, year,...)
field: DATETIME-String
You can also find some examples in the CCK Validation README.txt
Thank you...
Thank you... I think I understand now... One more thing, how should I handle multiple value fields? The validation rules should be written for each delta?
You can validate multiple
You can validate multiple values by running loops.
Multiple values are saved like
so you have to loop the first array.
Can anybody please tell me
Can anybody please tell me how can I add custom validation on CCK field in Drupal 6?
I found somewhere I will need CCK_validation module but its not available for D6.
Can anybody please help me out?
Thanks,
Fernando
You can use Rules for that.
You can use Rules for that.