I'm trying to implement an auto complete form with a little twist. I want its auto complete options to be limited by another field (text field to be more specific).
I understand how AJAX API works and should able to create an auto complete filter for a field based on it's own values but I have no idea how to create a an a auto complete filter based on another field in the form.
From what I have found only this question is similar to my problem, it is unfortunately unanswered. I don't want the code, just hint where to look would be useful.
BTW: I have came up with a solution but it's unbelievably dirty hack that requires going into database twice. I could implement AJAX callback for the field I want the filter to be based on, store the value of the field in the callback to custom database table and then in the callback of the field I want to filter get the value and make it work.
BTW2: The field I want to base the filter on will be text field, the other one custom entityreference.
BTW3: I'm almost sure it is possible somehow since the entityreference option limit module does something like that. (It does it with a help of one other field which I don't want (And I didn't understand it at all even though I tried anyway :) ))