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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

brandonc503 created an issue. See original summary.

brandonc503’s picture

FileSize
8.23 KB
8.73 KB
brandonc503’s picture

I'm not sure if I should be looking at the dash being inserted wrong, or the dash being read wrong.

brandonc503’s picture

Issue summary: View changes
legolasbo’s picture

Issue tags: -dash

@brandonc503,

My first guess is that it is being inserted wrong, but I currently don't have time to look into it myself.

legolasbo’s picture

Component: CCK / Field API widget » Taxonomy integration
Issue tags: -select or other, -terms, -hierarchy
brandonc503’s picture

Issue summary: View changes
brandonc503’s picture

FileSize
5.45 KB

Noticed this in html.. refer to image

legolasbo’s picture

Status: Active » Needs review
FileSize
640 bytes

Just a real quick untested patch, might break everything, might fix it, don't know ;)

brandonc503’s picture

Fresh install, dl module, then patch... did not 'help/fix'.
Results in image.

legolasbo’s picture

Allright,

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.

brandonc503’s picture

Checked "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.

legolasbo’s picture

FileSize
13.85 KB
21.03 KB

Let's try this again.

Attached patch fixes the notices and extends test coverage.

brandonc503’s picture

FileSize
8.98 KB

Sorry 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!

legolasbo’s picture

Found and fixed another notice, also fixed the whitespace issue you pointed out.

brandonc503’s picture

git 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...

brandonc503’s picture

patch on 7.x-3.0-alpha1 applied cleanly

  • legolasbo committed 97efb7e on 7.x-3.x
    Issue #2610910: Move taxonomy integration to it's own sub-module...
legolasbo’s picture

Status: Needs review » Fixed

Merged the patch from #16 into the fix of #2610910: Move taxonomy integration to it's own sub-module.

brandonc503’s picture

FileSize
15.12 KB

so 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)

brandonc503’s picture

FileSize
8.38 KB

seems i have some left over data. will test on core and see if actual issue, or my issue.

legolasbo’s picture

I 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 ;)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.