Pretty much a duplicate of FreeForm: Accessing a fields customAttributes but to answer Solspace's comment "Can you think of a use-case where you would apply attributes to a field but then render those manually?", yes I can.
My current project has Company entries and Equipment entries. Each user belongs to a single Company.
When a user fills out a form with a select field where source=entries and target=Equipment, I don't want the user to see all equipment in the system. Only equipment belonging to user's company.
I thought a clever idea would be to add field class "filterEquipment". When rendering my form
- if field.type=select and field class contains "filterEquipment" I want to loop through field options and only display equipment that belongs to user's company
- else render select field as normal
I'm open to other suggestions.