First of all, sorry for my English.
in someview.php I have the following code, basically I create a link with a url to a controlerID / accionID, and that should open a modal CJuiDialog given widget in a div (in this case propiedadDialog)
<?php
echo CHtml::ajaxLink(
Yii::t('sacApp', 'Add Propiedad'),
$this->createUrl("propiedad/addNew", array("idgrupo"=>$model->id)),
array(
'onclick'=>'$("#propiedadDialog").dialog("open"); return false;',
'update'=>'#propiedadDialog'
),
array(
'id'=>'showPropiedadDialog',
)
);
?>
<div id="propiedadDialog"></div>
This is the code of my action in the controller(PropiedadController.php)
<?php
public function actionAddNew($idgrupo, $_)
{
$model = new Propiedad;
$this->performAjaxValidation($model);
$flag = true;
if(isset($_POST['Propiedad'])){
$flag = false;
$model->attributes=$_POST['Propiedad'];
$model->idgrupo=$idgrupo;
//Do something before save
if($model->save()){
}
}
if($flag){
if(defined('YII_DEBUG')){
Yii::app()->clientScript->scriptMap['jquery.min.js'] = false;
}else{
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
}
$this->renderPartial('createDialog', array('model'=>$model), false, true);
}
}
?>
This is the createDialog.php called from the Controller
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog',
array(
'id'=>'propiedadDialog',
'options'=>array(
'title'=>Yii::t('propiedad', 'Create Propiedad'),
'autoOpen'=>true,
'closeOnEscape'=>true,
'modal'=>'true',
'width'=>'auto',
'height'=>'auto',
),
),
);
echo $this->renderPartial('_formDialog', array('model'=>$model));
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
Y este el _formDialog.php llamado desde createDialog.php
<?php
/* @var $this PropiedadController */
/* @var $model Propiedad */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'propiedad-form',
'enableAjaxValidation'=>true,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'descripcion'); ?>
<?php echo $form->textField($model,'descripcion',array('size'=>60,'maxlength'=>150)); ?>
<?php echo $form->error($model,'descripcion'); ?>
</div>
<div class="row buttons">
<?php //echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
<?php echo CHtml::ajaxSubmitButton(
Yii::t('propiedad', 'Create Propiedad'),
CHtml::normalizeUrl(array('propiedad/addnew', 'render'=>false)),
array(
'succes'=>'js:function(data){
$("#propiedadDialog").dialog("close");
}'
),
array(
'id'=>'closePropiedadDialog'
),
);?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
The problem I have is that when I click on the ajaxLink that must open the modal CJuiDialog, I returned the error "500 Internal Server Error"