How to create complicated conditionally linked fields?