Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In term reference, Drupal uses a dash (-) to show a child term. The dash in sub term is being used in the term with my select or other module; when it should be ignored.
the "other" is checked already and has Hats entered.)
here my node has Clothing and Hats term.. but since Hats is under Clothing it comes up -Hats.. which is not seen the same as Hats. If i was to now check -Hats, -Hats is added to vocab, so I then have -Hats and Hats
If i remove Hats from under parent then refresh node edit page..
Using the 7.3 dev btw. THANKS
Comment | File | Size | Author |
---|---|---|---|
#22 | facet number part.png | 8.38 KB | brandonc503 |
#21 | facets number term id.png | 15.12 KB | brandonc503 |
#16 | interdiff-14-16.txt | 1.5 KB | legolasbo |
#16 | dash_for_term_hierarchy-2598176-16.patch | 21.05 KB | legolasbo |
#15 | 2598176-14.patch.png | 8.98 KB | brandonc503 |
Comments
Comment #2
brandonc503 CreditAttribution: brandonc503 commentedComment #3
brandonc503 CreditAttribution: brandonc503 commentedI'm not sure if I should be looking at the dash being inserted wrong, or the dash being read wrong.
Comment #4
brandonc503 CreditAttribution: brandonc503 commentedComment #5
legolasbo@brandonc503,
My first guess is that it is being inserted wrong, but I currently don't have time to look into it myself.
Comment #6
legolasboComment #7
brandonc503 CreditAttribution: brandonc503 commentedComment #8
brandonc503 CreditAttribution: brandonc503 commentedNoticed this in html.. refer to image
Comment #9
legolasboJust a real quick untested patch, might break everything, might fix it, don't know ;)
Comment #11
brandonc503 CreditAttribution: brandonc503 commentedFresh install, dl module, then patch... did not 'help/fix'.
Results in image.
Comment #12
legolasboAllright,
I've had a proper look at this and it turned out to be a little more work then expected. Mainly because the original taxonomy implementation was using term names as values for the select widgets in stead of their term id. This was causing the initial bug, but was also the reason for a whole lot of complicated code. I ended up rewriting most of it + improving test coverage to also include a regression test for this bug.
Please test the attached patch. I'm quite sure it will solve this issue, but I'm not committing it until I've released the current state of 7.x-3.x-dev as 7.x-3.x-alpha1.
Comment #13
brandonc503 CreditAttribution: brandonc503 commentedChecked "Other" and entered term
Notice: Trying to get property of non-object in select_or_other_taxonomy_validate() (line 419 of /drupal/sites/all/modules/select_or_other/select_or_other.field_widget.inc).
Notice: Trying to get property of non-object in select_or_other_taxonomy_validate() (line 421 of /drupal/sites/all/modules/select_or_other/select_or_other.field_widget.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /drupal/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of /drupal/includes/entity.inc).
Notice: Trying to get property of non-object in taxonomy_term_save() (line 631 of /drupal/modules/taxonomy/taxonomy.module).
EntityMalformedException: Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 8024 of /drupal/includes/common.inc).
*also when i went in there after this patch , the other was checked with a 4 in the box. probably left overs from the other test.
Comment #14
legolasboLet's try this again.
Attached patch fixes the notices and extends test coverage.
Comment #15
brandonc503 CreditAttribution: brandonc503 commentedSorry this took so long, been busy.
On initial test seems to work great. I'll do more in next few days but love it. Thanks so much!
Comment #16
legolasboFound and fixed another notice, also fixed the whitespace issue you pointed out.
Comment #17
brandonc503 CreditAttribution: brandonc503 commentedgit apply -v dash_for_term_hierarchy-2598176-16.patch
Checking patch select_or_other.field_widget.inc...
error: while searching for:
}
/**
* Helper function to get the default taxonomy value.
*/
function select_or_other_taxonomy_default_value($items, $delta) {
// @todo this code seems odd. why perform the same check twice.
if (!empty($items[$delta]['tid'])) {
$term = taxonomy_term_load_multiple(array($items[$delta]['tid']));
$default_value = $items[$delta]['tid'] !== 'autocreate' ? $term[$items[$delta]['tid']]->name : NULL;
}
else {
$default_value = NULL;
}
return $default_value;
}
/**
* Implements hook_field_widget_form().
*/
function select_or_other_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
if ($field['type'] == 'taxonomy_term_reference') {
$default_value = select_or_other_taxonomy_default_value($items, $delta);
}
else {
$default_value = isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL;
}
// Construct the element.
error: patch failed: select_or_other.field_widget.inc:161
error: select_or_other.field_widget.inc: patch does not apply
Checking patch tests/select_or_other_taxonomy.test...
Comment #18
brandonc503 CreditAttribution: brandonc503 commentedpatch on 7.x-3.0-alpha1 applied cleanly
Comment #20
legolasboMerged the patch from #16 into the fix of #2610910: Move taxonomy integration to it's own sub-module.
Comment #21
brandonc503 CreditAttribution: brandonc503 commentedso noticed in my kickstart all products page the facets list id of product category ....
is this part of this module?
Product category
Configure
Apply 23 filter
23 (33) Apply 23 filter
Apply 4 filter
4 (27) Apply 4 filter
Apply 25 filter
25 (13) Apply 25 filter
Apply 9 filter
9 (9) Apply 9 filter
Apply 16 filter
16 (4) Apply 16 filter
Apply Tshirts filter
Tshirts (4) Apply Tshirts filter
Apply 3 filter
3 (3) Apply 3 filter
Apply 28 filter
28 (2) Apply 28 filter
Apply 5 filter
5 (2)
Comment #22
brandonc503 CreditAttribution: brandonc503 commentedseems i have some left over data. will test on core and see if actual issue, or my issue.
Comment #23
legolasboI BrandonC,
That issue is caused because search api does not make sure the term id referenced in a taxonomy_term_reference field belongs to a term that still exists when indexing content. I've worked around it for a project of my own by creating a filter plugin, but it would be better if search api would be fixed. But that's not an issue to discus here ;)