Limiting attribute fields in forms based on STI

I’m using single table inheritance. The values in the ‘type’ field
indicate the model names of the classes in the hierarchy.
I have a separate attributes table that lists the fields used by
each class in the hierarchy.

My question is: when I display a form to edit a record in the STI
table, how do I limit the fields shown in the form to those
appropriate to objects of that class?

I will get the list of approprate fields from my attributes table;
but how do I tell the model to only display form fields for those
attributes?

Thanks,
Peter