I'm writing a custom text field and widget module with ajax autocomplete from scratch. I want the lookup to work on one column, but I want another column's value (the looked-up item's id) to be saved as the field value in the node.
So, for example, user types for example
Sams, they accept suggestion
Samsung, but Drupal save its database identifier, say
Conversely, when opening the node for editing, the saved value of
145 should be again looked up, converted and displayed as
What is the key to get it working the Drupal way?