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
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

Status: Active » Needs review
FileSize
1.15 KB

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

agileadam’s picture

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

ekatja’s picture

Hi,
applying the last patch safeword_add_taxonomy_support-2329815-2.patch
for the stable release 7.x-1.9 I get this error:

patch -p 1 < ~/Source/patches/safeword_add_taxonomy_support-2329815-2.patch
patching file safeword.module
Hunk #3 FAILED at 370.
1 out of 3 hunks FAILED -- saving rejects to file safeword.module.rej

Patching the development release 7.x-1.8+1-dev works fine.

ekatja’s picture

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

agileadam’s picture

FileSize
43.53 KB

The reason it's not applying correctly is due to the addition of filter_xss_admin() and check_plain() in the latest releases.

safeword_changes

agileadam’s picture

Here's an updated patch that works with the latest changes in 7.x-1.x.

DamienMcKenna’s picture

I 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?

agileadam’s picture

That'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.

Robert Castelo’s picture

Status: Needs review » Fixed

Fixed 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).

agileadam’s picture

Thanks for fixing!

Status: Fixed » Closed (fixed)

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