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.
While most entities have a default field named "title", it does not work with taxonomy terms, instead the following error is reported in the browser upon opening a term edit page.
TypeError: 'undefined' is not an object (evaluating 'a.length')
each - jquery.min.js:2:17955
attach - safeword.js:35
(anonymous function) - drupal.js:76
each - jquery.min.js:2:18119
attachBehaviors - drupal.js:74
(anonymous function) - drupal.js:412
n - jquery.min.js:2:29308
fireWith - jquery.min.js:2:30073
ready - jquery.min.js:2:16008
B - jquery.min.js:2:20580
Comment | File | Size | Author |
---|---|---|---|
#6 | safeword_add_taxonomy_support-2329815-6.patch | 2.34 KB | agileadam |
#2 | safeword_add_taxonomy_support-2329815-2.patch | 2.18 KB | agileadam |
#1 | safeword-n2329815-1.patch | 1.15 KB | DamienMcKenna |
Comments
Comment #1
DamienMcKennaThis changes the $safeword_source variable handling to see if the $instance['entity_type'] is "taxonomy_term", if so it uses the 'name' field instead of the 'title' field.
Comment #2
agileadamExcellent work, DamienMcKenna.
Just to make things more clear to site administrators I've added a few more changes to your patch.
Also, I tested the unique option and it works as expected; it checks for uniqueness within the term's parent vocabulary only.
Nice job, and thanks!
Comment #3
ekatja CreditAttribution: ekatja commentedHi,
applying the last patch
safeword_add_taxonomy_support-2329815-2.patch
for the stable release 7.x-1.9 I get this error:
Patching the development release 7.x-1.8+1-dev works fine.
Comment #4
ekatja CreditAttribution: ekatja commentedUsing the development release 7.x-1.8+1-dev patched with
safeword_add_taxonomy_support-2329815-2.patch
creating taxomy field from type Machine name from node title or term name works fine.Using underscore _ as Replacement value it generates for Title
Test Underscore For Spaces ösak dök ajhskja 819829
Machine readable name
test_underscore_for_spaces_osak_dok_ajhskja_819829
which is correct (contains only lowercase letters, numbers, and underscores)
but I get the error
The machine-readable name must contain only lowercase letters, numbers, and underscores.
Comment #5
agileadamThe reason it's not applying correctly is due to the addition of filter_xss_admin() and check_plain() in the latest releases.
Comment #6
agileadamHere's an updated patch that works with the latest changes in 7.x-1.x.
Comment #7
DamienMcKennaI don't think it should say "node title", as the title field is used on many other entity types. There might be a more generic way of handling that aspect, maybe something in Entity API?
Comment #8
agileadamThat's a good point, and I agree.
It will always be an "entity" so perhaps "Entity title" would be fine?
I do like the idea of looking at what the entity API might give us.
It may take a form alter to update the field based on the current bundle.
Comment #12
Robert Castelo CreditAttribution: Robert Castelo commentedFixed in Safeword 7.x-1.11
Thanks for the patches agileadam and DamienMcKenna.
I added some customisation to the labels and descriptions so that they are context aware (node, taxonomy term).
Comment #13
agileadamThanks for fixing!