0

In Drupal 8, I use this code inside my buildForm() method:

$form['medias']['file'] = array(
  '#title' => t('Image'),
  '#type' => 'managed_file',
  '#upload_location' => 'public://image_example_images/',
  '#multiple' => true,
);

(Bad) Result: http://i.stack.imgur.com/ju0ZU.png

I would like know if it's possible to use a plugin of type "field widget" inside BuildForm() for call and use a field of Image type provided by the core of Drupal:

enter image description here Thanks.

0

Possible?

Probably. But it would require a lot of work, as you would basically have to provide all the data and calls that such plugins need. That is very likely more work than re-implementing this functionality yourself.

And creating an entity type would only make sense if you need to manage multiple "things" that each has images attached.

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.