Modal Create Dentro De Otro Create

Buenas tardes, Nuevamente acudo al foro en busca de respuestas. La cuestion es la siguiente. tengo un Formulario en mi TblEstructura donde me dice Tipo de Estructura. por lo que en el formulario puse un DropDownList que me trae de base de datos las opciones. quiero poner al lado del DropdownList un Agregar nuevo Tipo de Estrucrura. el cual me abra un Modal con el create del TblTipoestructura para crear un nuevo tipo de estructura. redireccionar al formulario de TblEstructura y encontrarlo dentro del DropDownList. Espero haberme explicado. lo que tengo en el TblEstructura/_form es lo siguiente:


	<div class="row">

		<?php echo $form->labelEx($model,'Tipo de Organismo'); ?>

		<?php echo $form->dropDownList($model,'idtipoestructura',

			CHtml::listData(TblTipoestructura::model()->findAll(),'id','denominacion'),

			array(

                    'ajax' => array(

                    'type' => 'POST',

                    //$("#padre").show();

                    //'url' => CController::createUrl('TblEstructura/SelectTO'),

                    'beforeSend' => 'function(){


	                    	if ($("#TblEstructura_idtipoestructura").val() == 2 ) {


	                    	$("#TblEstructura_idpadre option[value=]").attr("selected", "selected");

	                    	$("#padre").hide();


	                    	}else {


	                    	$("#padre").show();

	                    	

	                    	}

                    	}',

                ),'prompt' => 'Seleccione un Tipo de Organismo...'

            )

		); ?>


		<?php

		$this->beginWidget('zii.widgets.jui.CJuiDialog',array(

				'id' => 'ModalTipoEstructura',

				'options' => array(

					'title' => 'Formulario de Tipo de Estructura',

					'width'=>400,

					'height'=>400,

					'autoOpen'=>false,

					'resizable'=>false,

					'modal'=>true,

					'overlay'=>array(

						'backgroundColor'=>'#000',

						'opacity'=>'0.5'

						),

					),

			));


			echo $this->renderPartial('TblTipoestructura/create', array(

					'model'=> $model,

				));




		$this->endWidget('ii.widgets.jui.CJuiDialog'); 

		?>

		


		<?php echo CHtml::link('Agregar Nuevo Tipo de Organismo','', array('onclick'=>'$("#ModalTipoEstructura").dialog("open"); return flase;')); ?>

		




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

	</div>

Este el Error que me tira.


CException


TblEstructuraController no ha podido encontrar la vista "TblTipoestructura/_form" solicitada. 

Alguien puede ayudarme? es que estoy muy enredado.

Buenas.

A ver si te arreglas con esto:

Modal Create

Un saludo.

Ya lo pude hacer. gracias. si alguien sabe como se puede hacer para que la pagina anterior se actualice o mejor aun, solo el DropDownList se actualice para que me cargue el nuevo tipo de estructura creado. se lo agradeceria. aqui el codigo

Mi _form (TblEstructura)




<!-- ******************************************************************************************* -->

	<!-- ******************************************************************************************* -->

	<!-- ******************************************************************************************* -->


	<div class="row">

		<?php echo $form->labelEx($model,'Tipo de Organismo'); ?>

		<?php echo $form->dropDownList($model,'idtipoestructura',

			CHtml::listData(TblTipoestructura::model()->findAll(),'id','denominacion'),

			array(

                    'ajax' => array(

                    'type' => 'POST',

                    //$("#padre").show();

                    //'url' => CController::createUrl('TblEstructura/SelectTO'),

                    'beforeSend' => 'function(){


	                    	if ($("#TblEstructura_idtipoestructura").val() == 2 ) {


	                    	$("#TblEstructura_idpadre option[value=]").attr("selected", "selected");

	                    	$("#padre").hide();


	                    	}else {


	                    	$("#padre").show();

	                    	

	                    	}

                    	}',

                ),'prompt' => 'Seleccione un Tipo de Organismo...'

            )

		); ?>


		<?php echo CHtml::link('Agregar Nuevo Tipo de Organismo','', 

			array(

		'style'=>'cursor: pointer; text-decoration: underline;',

		//'onclick'=>'$("#ModalTipoEstructura").dialog("open"); return false;'));

		'onclick'=>"{addTipoEstructura(); $('#ModalTipoEstructura').dialog('open');}"));?>




		<?php $this->beginWidget('zii.widgets.jui.CJuiDialog',array(

				'id' => 'ModalTipoEstructura',

				'options' => array(

					'title' => 'Crear Tipo de Organismo / Ente',

					'width'=>800,

					'height'=>500,

					'autoOpen'=>false,

					'resizable'=>false,

					'scrollable'=>true,

					'modal'=>true,

					'overlay'=>array(

						'backgroundColor'=>'#000',

						'opacity'=>'0.5'

						),

					),

			));?>




		<div class="divForForm"></div>


		<?php $this->endWidget('zii.widgets.jui.CJuiDialog');?>

		




		<script type="text/javascript">

		// here is the magic

		function addTipoEstructura()

		{

		    <?php echo CHtml::ajax(array(

		            'url'=>array('TblTipoestructura/create'),

		            'data'=> "js:$(this).serialize()",

		            'type'=>'post',

		            'dataType'=>'json',

		            'success'=>"function(data)

		            {

		                if (data.status == 'failure')

		                {

		                    $('#ModalTipoEstructura div.divForForm').html(data.div);


		                    $('#ModalTipoEstructura div.divForForm form').submit(addTipoEstructura);

		                }

		                else

		                {

		                    $('#ModalTipoEstructura div.divForForm').html(data.div);

		                    setTimeout(\"$('#ModalTipoEstructura').dialog('close') \",3000);

		                }

		 

		            } ",

		            ))?>;

		    return false; 

		 

		}

		 

		</script>




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

	</div>


	<!-- ******************************************************************************************* -->

	<!-- ******************************************************************************************* -->

	<!-- ******************************************************************************************* -->



El ActionCreate en TblTipoestructura




public function actionCreate()

    {

        $model=new TblTipoestructura;

 

        if(isset($_POST['TblTipoestructura']))

        {

            $model->attributes=$_POST['TblTipoestructura'];

            if($model->save())

            {

                if (Yii::app()->request->isAjaxRequest)

                {

                    echo CJSON::encode(array(

                        'status'=>'success', 

                        'div'=>'El Tipo de Organismo / Ente se ha Agregado Correctamente'

                        ));

                    exit;               

                }

                else

                    $this->redirect(array('view','id'=>$model->id));

            }

        }

 

        if (Yii::app()->request->isAjaxRequest)

        {

            echo CJSON::encode(array(

                'status'=>'failure', 

                'div'=>$this->renderPartial('create', array('model'=>$model), true)));

            exit;               

        }

        else

            $this->render('create',array('model'=>$model,));

    }



En lugar de un link podrías utilizar un AJAX link. Ponle un id a tu dropdownlist, por ejemplo "tipoEstructuraId".




echo CHtml::ajaxLink(

'Nuevo Tipo de Organismo',

$this->createUrl('TblTipoestructura/ajaxCreate'),

array(

     'onclick'=>'$("#ModalTipoEstructura").dialog("open"); return false;',

     'update'=>'#tipoEstructuraId',

     ),

array(

     'id'=>'createTipoEstructura',

));



Y te creas una acción llamada ajaxCreate que no haga un render al final. Que añada un nuevo tipo de estructura pero que no añada un render.