1

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.

1 Answer 1

1

A suggestion from Freeform support:

The only way you might be able to achieve this would be if you used a regular Text field (inside of Composer), and then override the formatting template to manually render the field as a select dropdown and populate the options dynamically. Actual fields with options such as Select fields need to have all of their options pre-defined inside Composer, which is why it wouldn't work otherwise. Using the element populators could almost get you there, but it doesn't allow dynamic filtering like what you'd need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.