Hello,
I am working on a custom module, in which i am using hook_validate() to add custom validations to my web page. I've got an image field to my web page, which i want to be required as well as other image validations like size and type also need to be put in, i tried following code as well to use drupal's builtin validate functionality:
$form['image'] = array(
'#type' => 'file',
'#title' => t('Photo1'),
'#weight' => 7,
'#required' => TRUE,
'#description' => t('Click "Browse..." to select an image to upload.'));
But,it didn't work.
Please suggest me a way to do this!
Thanks,
Kul
Comments
hook_validate() only works in
hook_validate() only works in modules where you are creating a custom content type. To create a validation function for any other form, just add _validate to the name of the function that drupal_get_form() calls.
Contact me to contract me for D7 -> D10/11 migrations.
Yes, i am creating a custom
Yes, i am creating a custom content type, and my other validations are working under the validate hook. Its just that i am not getting a way to put image validation in this hook in drupal way.