I'm trying to do the same thing with an email preference center. I'd like to use a hidden field to drive visibility rules on a form.
I just decided that I need to determine a way to elegantly include the field (unhidden) into the form. Wish there was a better way.
You just need to reverse your approach, as I mentioned on another thread on the same topic.
Do use Marketo's built-in hidden field functionality to read from query params or cookies. It's not worth reimplementing that part.
But then use those hidden fields as data sources for additional logic.
In this demo the hidden `Last Name` field is taken from the query param `LN`, if present.
Then the hidden field is unhidden and inserted into the form.
The regular field `Middle Name` has a Visibility Rule applied so it will only be shown if the hidden `Last Name` was not empty.
The Forms 2.0 API (JavaScript) ties together the standard form field types/configs to create special UI behavior.