Field saving with renderPartial() (EAV style)

I am trying to make my own EAV implementation, and I am stumbled upon this problem.

EAV will have these types:

text, catalog, article

text is a single textarea.

catalog is a complex view that renders a list of books from a database and returns multiple values delimited with (,)

article is a complex view that uses CKEditor with a template (practically a textbox).

My EAV implementation is as follows:


avid (PK)

field_id (where the types of text, catalog, article are stored)

section_id (where the section I want to place them is)

value (the variable value)


I have already saved all the fields but for value I use a dropdownlist in the form.

Depending on the dropdownlist value (1,2,3) it brings me a partial view via ajax.

	<div class="row">

		<?php echo $form->labelEx($model,'attributeid'); ?>

		<?php //echo $form->textField($model,'attributeid'); 

			echo $form->dropDownList($model,'attributeid',CHtml::listData(Attributes::model()->findAll(),'attributeid','name'),


				'prompt' => 'Επιλογή control',

				'ajax' => array(

					'type' => 'POST',

					'url' => CController::createUrl('attributeValues/dynamiccontent'),





		<?php echo $form->error($model,'attributeid'); ?>


	<div class="row">

		<?php echo $form->hiddenField($model,'value'); ?>


	<div id="dynamic_content"></div>

My controller has this:

	public function actionDynamiccontent()



		if (isset($_POST['AttributeValues']['attributeid']) && !empty($_POST['AttributeValues']['attributeid'])) {

			$id = intval($_POST['AttributeValues']['attributeid']);

			$myAttrib = Attributes::model()->findByPk($id)->getAttributes();

			$params = array('field_type'=>$myAttrib,'data'=>$_POST['AttributeValues']);




And finally my _ajaxContent has this code:

<div class="row">



	switch ($field_type['type']) {

		case "catalog":

			$criteria = new CDbCriteria();

			$criteria->condition = "showme=1";

			$criteria->select = 'id,title';

			$model1 = Products::model()->findAll($criteria);

			//echo CHtml::textField('productid',$data['value']);

			echo CHtml::dropDownList('productid',$data['value'],CHtml::listData($model1,'id','title'),array('multiple'=>'multiple', 'size'=>5));


		case "text":

			echo CHtml::textField('productid',$data['value']);



			echo "Default.";




When I try to save the record, I get no value (since it’s saved on productid), so a little bit of jquery is required (on top of _form.php) :


$myJQuery = <<<EOF

	$(document).ready(function() {


			var type = 'text';

			$('#productid').each(function(i,t) {

				type = t.type;


			if (type == 'select-multiple') {

				var multipleValues = $('#productid').val() || [];

				var pid = multipleValues.join(',');

				alert('Multiple Value PID:'+pid);


			} else {

				var pid = $('#productid').val();

				alert('Single Value PID:'+pid);



			return true;






Yet, here is where I get a bump, since I am saving the value to AttributeValue_value field (hidden), but when it goes to actionUpdate() or actionCreate(), it still shows my field empty.

So is there any way to get the $form->value inside the partial view or a way to save properly the missing field?

Thanks in advance.