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.

10
  • 1
    I used to autocomplete deluxe for this but not sure about how it works with inline entity form. drupal.org/project/autocomplete_deluxe Worked really well. Commented Mar 1, 2016 at 13:38
  • @NiallMurphy, I used this module for another project. It doesn't do what I want. Thanks.
    – herci
    Commented Mar 1, 2016 at 19:12
  • Are Name and Surname also taxonomy fields? Regular fields?
    – Kevin
    Commented Mar 4, 2016 at 18:21
  • How is this question different from this one? drupal.stackexchange.com/questions/193046/… Commented Mar 5, 2016 at 11:46
  • @Kevin, no name and surname are regular fields.
    – herci
    Commented Mar 5, 2016 at 11:47

1 Answer 1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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