0

I wanna add in a block configuration form an image field that can take several images, just like in a node form, with all the drag'n drop stuff, etc. Any advices or solutions?

0

The solution is an image field configured in a custom block type.

Block forms are configuration and don't support image fields. Custom block types are content and they support the same field types as nodes.

If you can't do what you want with a custom block type, you can create your own block plugin which uses a block content entity.

For background information see these questions Adding custom block problems and Blocks: Old vs. "Custom" and Config vs. Fields.

| improve this answer | |
  • In fact, I use the hook_block_configure to add an image_field in my form, but I can only upload one image by field. – Gwaldhorf Miopau Apr 11 '17 at 12:34
  • Then this is for D7, the problem is basically the same, but the solution is different, see drupal.stackexchange.com/questions/103180/… – 4k4 Apr 11 '17 at 12:42
  • Yep, I already use $form[xxx] with the managed file parameters but for exemple i got a slider with 5 images, i have to add 5 image field in my form. What i want to do is to have only one field for my five images. (I'm sorry if I made mistakes or don't understand, I'm french and my english is not perfect. :) ) – Gwaldhorf Miopau Apr 11 '17 at 13:03
  • The issues with image fields in configuration are perfectly described in the linked questions. It might be easier to take a different route and use a node type or entity type with an image field. – 4k4 Apr 11 '17 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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