-1

I want to achieve (Create a form that will allow the user to select files from server) in Drupal 8.3 and have followed steps 1 to 4 but for some reason it's not working at my end.

Can someone shed light how code can be updated in Drupal 8.3 to achieve above?

Thanks

0

I dont know the exact code to be used for ur scenario. but i was referred the attached link in your question. some of the methods are depreciated in drupal 8 . like drupal_add_js .

Please refer below link. so you will get some idea.

https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-module

and also hook_menu is depreciated in drupal 8. All route configuration is done via routing. yml.file

Below links may helpfull to you. https://www.drupal.org/docs/8/api/routing-system/structure-of-routes

  • Thanks but I already know above ref links and have successfully attached js. But my problem still remains unresolved. – webdevfreak Aug 7 '17 at 14:15
0

I have achieved this in version 8.3 by enabling IMCE module and with the following logic i.e

1)

<script>
  function imageFileSelector() {
    window.open('/imce?urlField=edit-image-file-path-1', '', 'width=760,height=560,resizable=1');
  }
</script>

'edit-image-file-path-1' is id value for form field 'image_file_path_1'.

2)

$form['image_file_selector'] = array(
  '#markup' => t("<br /><b>Image File *</b><br><a onclick=imageFileSelector();>Click to choose Image File</a><br>"),
);
$form['image_file_path_1'] = array(
  '#type' => 'textfield',
  '#attributes' => array('readonly' => 'readonly'),
  '#default_value' => $result->image_file_path_1,
);

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