Addtional model functions based on xml field

Hi all,

Im kinda new to yii and im stuck on the following:

I basically have a model ‘Brick’ which is an CActiveRecord. It has some fields to store in the database. One of those fields is the ‘data’ field. In the data field an xml structure is stored and based on the XML structure yii must load the correct widget.

For example:

the xml is <Text></Text> it should load a Text widget which has additional fields in the XML e.g. content, color, alignment, etc.

if the xml is <ImageGallery></ImageGallery> the imageGallery widget should be loaded.

This is currently working with the use of widgets.

my problem now is that besides rendering the correct component. the component should also be editable and therefor need customized forms per component. When editing the component, the form should be serialized to xml and the xml should be saved in the Brick model and back to the database.

Currently im using a ‘BrickRenderer’ widget to get al the bricks from the database, check the component type en render the appropriate widget. Is this the correct way to process this or should i be looking at modules or something else?

My goal is to set it up as generic a possible, so that creating a new component would be as simpel as placing 1 folder in the extension folder and everything (viewing/editing) should work.

Hope someone can help me out a bit,

Kind regards,