Dynamically adding properties to a Form Model

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…


After some digging, I think I am going to end up doing the following:

  1. Add a private array called "dynamicValues" for storing data for dynamic properties.

  2. Add a "dynamicAttributeNames" property for storing the names of dynamic attributes.

  3. 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.

same topic : dynamicModel


Thanks… I posted my solution in that thread.