3

I'm using the Entity Reference module to relate different unique, particular pieces of equipment (identified by unique serial numbers) to different orders. Equipment and orders are content types. On the Order content type, I have an entity reference field with an inline entity form widget (autocomplete) for the user to scan in the serial number and form the relationship.

The problem is, the serial numbers could be in Hexidecimal or Decimal format, and the users should be able to use both interchangeably. Thus, if a user is creating an order and scans in the decimal serial number, the system should be smart enough to associate that with the correct piece of equipment, even if that serial number was entered in hex.

Entity Reference seems to have a limitation here, in that all of the widgets I've found seem to only reference the "title" attribute of an entity. Is there a way to make this attribute support multiple values, or to have Entity Reference reference nodes using multiple uniquely-valued fields (or maybe a single field with multiple globally-unique values)?

0

Ok, I've thought of a solution that somewhat inelegant, but it works

On the Equipment content type, a hex/dec signifier field is added--some sort of a select box (maybe a taxonomy selection box) where the user will select if the serial number in hex or dec.

When the form is submitted, a custom rule will check for the presence of the select box, convert the value in the "title" to the other numbering format, and then append that value to the original value in the title field, so that the title field will contain both formats of the number. After everything is said and done, the Equipment titles will all look like "1234567, 12D687".

Now, when the user creates an order and searches for existing serial numbers using the Inline Entity Form, as long as you have it set to "autocomplete", it will find the correct piece of equipment and associate it with the order.

Still, it would be nice if Entity Reference auto-complete would work with fields from those entities and not just their titles. And, I'm still in needs of some sort of module that will add a hex converter to Rules.

Let me know if anyone finds better solutions!

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.