2

There are two Fields, Image and Video Users have to use only one field, image or video. The problem is how do I remove video field if user upload a image ? is there any custom validation for this ?

Thanks

2 Answers 2

2

The Conditional fields module can do this. It allows to set up conditions and dependencies between multiple files (for example, only show field X if field Y is filled/checked).

4
  • I'm already using Conditional fields but it's only show and hide fields. if user upload image and edit the node and upload a new video both of them is allowed to upload. I need a validation of this.
    – kLezer
    Jun 18, 2011 at 23:08
  • I guess the problem here is that images/files are kinda special. Once you've uploaded a file, there is no form field anymore so your conditional field rule does not match anymore. Maybe you can inverse it (Instead of hide the video field if image is filled, change it to show the video field as long as the image field is empty). Untested. You could also ask that (how to make a rule that works for this) as a question.
    – Berdir
    Jun 19, 2011 at 12:05
  • @kLezer This is a perfect example why you need to put all relevant information in the question and explain more what your problem is. I'd have been able to give you the comment above as an answer to your question initially... With the given information, there was no way for me to know that you are already using conditional fields.
    – Berdir
    Jun 19, 2011 at 12:06
  • Thank you Berdir, I'll create a custom module for validation. first trial was successful...
    – kLezer
    Jun 19, 2011 at 18:33
0

You have to use hook_form_alter to add your own validate handler to your content type form. For example code View this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.