1

in the media module's settings, there's a checkbox called "Skip available fields" that lets you skip filling out fields that are attached to your media when you add one.

In some cases, we need to let users enter a description for files that are uploaded and in other cases, no.

Does anybody know how to skip the available fields for a specific field of a specific content type ? What kind of code or hook implementation is required, etc. ...

Thanks !

1 Answer 1

0

You could probably acheive that by implementing

hook_field_attach_form

and setting the required values (e.g #required => TRUE or unsetting the description element.).

The entity_type and entity values are available for conditionally showing / hiding data there.

3
  • Is there a way to name that hook so that it applies only to a specific content type ? Because with the variables available, I can see that the description field is attached to my document file type but I don't see to which content type that document is attached ... so the hook applies to every description field, which is not what I want.
    – agodin
    Sep 30, 2014 at 15:54
  • @agodin yes, the entity object is passed as a parameter so you can just check $entity->type Sep 30, 2014 at 21:44
  • But $entity->type returns the value "document", which is the name of the filetype the description field is attached to ... I need to know the content type (blog post, article, etc.) of the field of type "document" that it's attached to. Because for example, for content type "blog post", I'll want to use the description field and for content type "article", I want to skip it ...
    – agodin
    Oct 1, 2014 at 21:53

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.