9 – Find value of another field in a fieldformatter

This may be complicated to explain

I have a content type with field_1, field_2 etc

field_1 is a taxonomy reference

field_2 is a custom field with various sub-values

I have a custom formatter for field_2 which does all sorts of things to hang the sub-values into the desired output, however, I now have a condition for a certain value of field_1 which requires a different formatting to happen to field_2 that is not dependent on the field_2 values.

I need the formatter to handle this as the field will be required in various output scenarios (custom module, views, XML export) and I don’t want to have to build multiple mechanisms for handling the data.

My question therefore is how I can grab field_1 from within the formatter of field_2 so that I can apply conditional format logic to it.

I could modify field_2 to contain a flag to control this formatting, however, there are > 20K records to add a value to whereas it’s 1 additional field in a taxonomy record where there are less than 25 values, it would also allow an editor to set the formatting flag independently of the selected taxonomy and potentially an incorrectly displayed value. I can pass values to the formatter from custom module code, however, this needs to be applied when a “normal” user creates their own view or other brings back the field into a view or page.

Hope this makes sense