Guest User

Untitled

a guest
Nov 30th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. public function buildForm(array $form, FormStateInterface $form_state){
  2. $form = array();
  3.  
  4. $form['adherent_id'] = array(
  5. '#type' => 'email',
  6. '#prefix' => '<div class="db f5 dark-gray text textinp textinp2">Adherent</div >',
  7. '#default_value' => '',
  8. '#required' => TRUE,
  9. '#autocomplete_route_name' => 'simulation.autocomplete',
  10. '#attributes' => array(
  11. 'id' => 'AdherentId',
  12. 'class' => array('b', 'pa3', 'input-reset', 'ba', 'bg-transparent', 'hover-bg-moon-gray', 'hover-black', 'w-100'),
  13. ),
  14. );
  15.  
  16. return $form;
  17. }
  18.  
  19. simulation.autocomplete:
  20. path: '/simulator/autocomplete'
  21. defaults:
  22. controller: 'DrupalsmenoControllerAdminController::autocomplete1'
  23. requirements:
  24. _access: 'TRUE'
  25.  
  26. <?php
  27.  
  28. namespace DrupalsmenoController;
  29.  
  30. use DrupalCoreControllerControllerBase;
  31. use SymfonyComponentHttpFoundationRequest;
  32. use SymfonyComponentHttpFoundationJsonResponse;
  33.  
  34. class AdminController extends ControllerBase {
  35.  
  36. function autocomplete1(request $request){
  37. $typed_category = $request->query->get('q');
  38. $matches = [
  39. '0' => 'user@mail.com',
  40. '1' => 'nina@mail.com',
  41. '2' => 'pierre-jr@mail.com'
  42. ];
  43. return new JsonResponse($matches);
  44. }
  45.  
  46. }
Add Comment
Please, Sign In to add comment