I’m working on a project which involves generating some forms dynamically. Can anyone recommend the best way to dynamically create a form model, without having to pre-define all of the fields in the class as public properties?
I haven’t dug into the code of the form model yet, but I’m guessing I’ll have to extend the class and do some hacking…
edit:
After some digging, I think I am going to end up doing the following:
-
Add a private array called "dynamicValues" for storing data for dynamic properties.
-
Add a "dynamicAttributeNames" property for storing the names of dynamic attributes.
-
Override the "__set" and "__get" magic methods to see if the property being set is dynamic and store/retrieve it from the right data structure.