How to add taxonomy term reference field in a custom form

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
6
down vote

favorite
1












In the previous version of Drupal, it was possible to reference taxonomy tags in Drupal's forms using the following option:



'#autocomplete_path' => 'taxonomy/autocomplete/'.$vid,


However, in the Drupal 8, taxonomy term reference field has been removed in favor of Entity reference, more info here.



So, is there any alternative available?







share|improve this question




























    up vote
    6
    down vote

    favorite
    1












    In the previous version of Drupal, it was possible to reference taxonomy tags in Drupal's forms using the following option:



    '#autocomplete_path' => 'taxonomy/autocomplete/'.$vid,


    However, in the Drupal 8, taxonomy term reference field has been removed in favor of Entity reference, more info here.



    So, is there any alternative available?







    share|improve this question
























      up vote
      6
      down vote

      favorite
      1









      up vote
      6
      down vote

      favorite
      1






      1





      In the previous version of Drupal, it was possible to reference taxonomy tags in Drupal's forms using the following option:



      '#autocomplete_path' => 'taxonomy/autocomplete/'.$vid,


      However, in the Drupal 8, taxonomy term reference field has been removed in favor of Entity reference, more info here.



      So, is there any alternative available?







      share|improve this question














      In the previous version of Drupal, it was possible to reference taxonomy tags in Drupal's forms using the following option:



      '#autocomplete_path' => 'taxonomy/autocomplete/'.$vid,


      However, in the Drupal 8, taxonomy term reference field has been removed in favor of Entity reference, more info here.



      So, is there any alternative available?









      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 9 at 17:59









      Pierre.Vriens

      35k1334154




      35k1334154










      asked Aug 9 at 13:46









      Hedeshy

      2169




      2169




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          7
          down vote



          accepted










          Well, I have found the way in the change records. take a look at: https://www.drupal.org/node/2418529



          Here is the example options for taxonomy fields:



          '#type' => 'entity_autocomplete',
          '#target_type' => 'taxonomy_term',
          '#selection_settings' => [
          'target_bundles' => array($vid1, $vid2),
          ],





          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "220"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f267261%2fhow-to-add-taxonomy-term-reference-field-in-a-custom-form%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            7
            down vote



            accepted










            Well, I have found the way in the change records. take a look at: https://www.drupal.org/node/2418529



            Here is the example options for taxonomy fields:



            '#type' => 'entity_autocomplete',
            '#target_type' => 'taxonomy_term',
            '#selection_settings' => [
            'target_bundles' => array($vid1, $vid2),
            ],





            share|improve this answer
























              up vote
              7
              down vote



              accepted










              Well, I have found the way in the change records. take a look at: https://www.drupal.org/node/2418529



              Here is the example options for taxonomy fields:



              '#type' => 'entity_autocomplete',
              '#target_type' => 'taxonomy_term',
              '#selection_settings' => [
              'target_bundles' => array($vid1, $vid2),
              ],





              share|improve this answer






















                up vote
                7
                down vote



                accepted







                up vote
                7
                down vote



                accepted






                Well, I have found the way in the change records. take a look at: https://www.drupal.org/node/2418529



                Here is the example options for taxonomy fields:



                '#type' => 'entity_autocomplete',
                '#target_type' => 'taxonomy_term',
                '#selection_settings' => [
                'target_bundles' => array($vid1, $vid2),
                ],





                share|improve this answer












                Well, I have found the way in the change records. take a look at: https://www.drupal.org/node/2418529



                Here is the example options for taxonomy fields:



                '#type' => 'entity_autocomplete',
                '#target_type' => 'taxonomy_term',
                '#selection_settings' => [
                'target_bundles' => array($vid1, $vid2),
                ],






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 9 at 14:04









                Hedeshy

                2169




                2169



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdrupal.stackexchange.com%2fquestions%2f267261%2fhow-to-add-taxonomy-term-reference-field-in-a-custom-form%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Confectionery