diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php b/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php index fec2bfe..cce65c2 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php @@ -283,6 +283,7 @@ protected function build_filters(&$form, &$form_state) { // "Autocomplete term widget (tagging)" widget. if ($instance['widget']['type'] == 'taxonomy_autocomplete') { $tag_fields[] = $instance['field_name']; + $bundle_names[$instance['field_name']] = $bundle; } } } @@ -304,7 +305,7 @@ protected function build_filters(&$form, &$form_state) { $form['displays']['show']['tagged_with'] = array( '#type' => 'textfield', '#title' => t('tagged with'), - '#autocomplete_path' => 'taxonomy/autocomplete/' . $tag_field_name, + '#autocomplete_path' => 'taxonomy/autocomplete/' . $tag_field_name . '/' . $entity_type . '/' . $bundle_names[$tag_field_name], '#size' => 30, '#maxlength' => 1024, '#field_name' => $tag_field_name, diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 1dbe5f8..ef7c440 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -214,7 +214,7 @@ function testNodeTermCreationAndDeletion() { // Test autocomplete on term 3, which contains a comma. // The term will be quoted, and the " will be encoded in unicode (\u0022). $input = substr($term_objects['term3']->name, 0, 3); - $json = $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id(), array('query' => array('q' => $input))); + $json = $this->drupalGet('taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id() . '/node/article', array('query' => array('q' => $input))); $this->assertEqual($json, '{"\u0022' . $term_objects['term3']->name . '\u0022":"' . $term_objects['term3']->name . '"}', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term3']->name))); // Test autocomplete on term 4 - it is alphanumeric only, so no extra @@ -228,7 +228,7 @@ function testNodeTermCreationAndDeletion() { $tag = $this->randomName(); $message = t("Taxonomy field @field_name not found.", array('@field_name' => $field_name)); $this->assertFalse(field_info_field($field_name), format_string('Field %field_name does not exist.', array('%field_name' => $field_name))); - $this->drupalGet('taxonomy/autocomplete/' . $field_name, array('query' => array('q' => $tag))); + $this->drupalGet('taxonomy/autocomplete/' . $field_name . '/node/article', array('query' => array('q' => $tag))); $this->assertRaw($message, 'Autocomplete returns correct error message when the taxonomy field does not exist.'); } @@ -252,7 +252,7 @@ function testTermAutocompletion() { // Try to autocomplete a term name that matches both terms. // We should get both term in a json encoded string. $input = '10/'; - $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id(); + $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id() . '/node/article'; // The result order is not guaranteed, so check each term separately. $result = $this->drupalGet($path, array('query' => array('q' => $input))); $data = drupal_json_decode($result); @@ -262,14 +262,14 @@ function testTermAutocompletion() { // Try to autocomplete a term name that matches first term. // We should only get the first term in a json encoded string. $input = '10/16'; - $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id(); + $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id() . '/node/article'; $this->drupalGet($path, array('query' => array('q' => $input))); $target = array($first_term->name => check_plain($first_term->name)); $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns only the expected matching term.'); // Try to autocomplete a term name with both a comma and a slash. $input = '"term with, comma and / a'; - $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id(); + $path = 'taxonomy/autocomplete/taxonomy_' . $this->vocabulary->id() . '/node/article'; $this->drupalGet($path, array('query' => array('q' => $input))); $n = $third_term->name; // Term names containing commas or quotes must be wrapped in quotes. diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index b82d3aa..7003428 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -308,10 +308,10 @@ function taxonomy_menu() { 'type' => MENU_CALLBACK, 'file' => 'taxonomy.pages.inc', ); - $items['taxonomy/autocomplete/%'] = array( + $items['taxonomy/autocomplete/%/%/%'] = array( 'title' => 'Autocomplete taxonomy', 'page callback' => 'taxonomy_autocomplete', - 'page arguments' => array(2), + 'page arguments' => array(2, 3, 4), 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, 'file' => 'taxonomy.pages.inc', diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc index 2752d05..a7ad2c0 100644 --- a/core/modules/taxonomy/taxonomy.pages.inc +++ b/core/modules/taxonomy/taxonomy.pages.inc @@ -100,13 +100,17 @@ function taxonomy_term_feed(Term $term) { * }; * @endcode * - * @param $field_name + * @param string $field_name * The name of the term reference field. + * @param string $entity_type + * The entity type for the instance. + * @param string $bundle_name + * The bundle name for the instance. * * @see taxonomy_menu() * @see taxonomy_field_widget_info() */ -function taxonomy_autocomplete($field_name) { +function taxonomy_autocomplete($field_name, $entity_type, $bundle_name) { // A comma-separated list of term names entered in the autocomplete form // element. Only the last term is used for autocompletion. $tags_typed = drupal_container()->get('request')->query->get('q'); @@ -142,8 +146,8 @@ function taxonomy_autocomplete($field_name) { } // @todo Get the match anywhere value from the field widget setting. - // $match = $field->getWidget->getSetting('match'); - // $match = drupal_container->get('something')->createInstance['widget']['settings']['match']; + // $instance = field_info_instance($entity_type, $field_name, $bundle_name); + // $match = $instance['widget']['settings']['match']; $match = "anywhere"; switch ($match) { case 'start':