6

I have a content type book and it has a taxonomy term reference field: author.

I want to enter name and surname separately for each author on node add/edit page. Name and surname together will be the taxonomy term.

If I enter John for the name and Smith for the surname the taxonomy term will be John Smith.

enter image description here

I'm doing this by using the Inline Entity Form module with the Automatic Entity Label module.

The problem here is: the Inline Entity Form has two options while entering the term:

  1. Add new term
  2. Add existing term.

enter image description here

If you don't know if the term exists or not it become useless.

What I need is only one option and if the entered [name + surname] exist then select it as author automatically and if that not exist create a new term.


How can I do this?

(Similar structure can be created with some different methods such as References Dialog module, Entity Connect module etc but the main problem exist there too.)


Note: This question is not a duplicate of "How to create a name-surname structure for taxonomy terms?" ... even though they use the same image. In this question the main point is "how to combine creating new term and choosing existing one options", in the other question "how to create a name-surname structure on node form" is asked.

2

This solution is a bit "out there" so I'll just describe the logic.

  1. Three taxonomy fields. One for first name, one for last name (so there's autocomplete), one for full name generated by rules.

  2. On node save, join the first+last as tokens and fetch term by property name. This will give a list containing one or no terms.

  3. Two rules components that receive the list.

  4. No. 1: condition, list is empty. Actions. Create term and send it back to the rule.

  5. No. 2: condition, list is not empty. Actions. Send back the fetched term.

  6. In the main rule, set data value on node, returned terms.

It's "out there" but that's because there are two fields for one term.

  • Thanks for your answer, but to be honest I couldn't get the point, how to implement this. – herci Mar 7 '16 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.