Managing Nested Models

Hi all,

I’m setting up a generic social networking application where users have profiles, but the fields in these profiles are not static, but can be managed by the administrator of the app.

Right now, I have a Profile, Field and Field_Value model:

The Field model saves the metadata for a field, like its type, whether it’s required or not, and the display order.

The Field_Value model saves the value of such a field per user.

Now, I obviously want users to be able to edit their profiles, so the profile/edit action should collect all applicable Fields, retrieve their values and save them to the Field_Value model where necessary.

Since I’m kind of new to this MVC thing, I’m looking for some input on how to elegantly handle this situation. Any ideas are appreciated :)

the view is like this




foreach ($fields as $i=>$field) {


<div class="simple">

<?php echo MyHelper::activeLabelEx($field,$field); ?>


<?php echo CHtml::activeTextField($field,"[$i]field"); ?>

or

<?php echo CHtml::activeTextField($field,$field->name); ?>


</div>

            

    }



see http://www.yiiframework.com/doc/guide/form.table

Ah, I totally missed that when I checked the guide. Thanks, that got me started :)