Hello I hope you can help me
sorry for my English
I have a modal form where events are logged and in the same form shows in a cgridview the events previously registered, my need is to click on a row of the cgridview update the model that is loaded and show the data for editing.
in view
<div class="row">
<div class="row-inline6">
<?php
$htmlOptions = array('style'=>'font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em');
echo $form->labelEx($model,'sqrid',$htmlOptions); ?>
</div>
<div class="row-inline5">
<?php
$htmlOptions = array(
'style'=>'font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em; width: 200px',
'empty'=>'Seleccione SQR',
);
echo $form->dropDownList($model,'sqrid', Sqr::model()->getListaSqr(),$htmlOptions); ?>
<?php echo $form->error($model,'sqrid'); ?>
</div>
</div>
<div class="row">
<div class="row-inline6">
<?php
$htmlOptions = array('style'=>'font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em');
echo $form->labelEx($model,'dapertura',$htmlOptions);
?>
</div>
<div class="row-inline5">
<?php $this->widget("zii.widgets.jui.CJuiDatePicker",array(
"attribute"=>"dapertura",
"id"=>"date-sqr-id",
"model"=>$model,
"language"=>"es",
"options"=>array(
"dateFormat"=>"yy-mm-dd",
'showButtonPanel' => true,
'changeMonth' => true,
'changeYear' => true,
'yearRange' => '-80:+10',
'minDate' => '-1Y',
'maxDate' => '+1Y',
),
'htmlOptions'=>array(
'size'=>14,
'maxlength'=>14,
'style'=>'align: "left"; font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em;'
),
)); ?>
<?php echo $form->error($model,'dapertura'); ?>
</div>
<div class="row-inline6">
<?php
$htmlOptions = array('style'=>'font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em');
echo $form->labelEx($model,'dcierre',$htmlOptions);
?>
</div>
<div class="row-inline5">
<?php
$htmlOptions = array('style'=>'font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em');
echo $form->textField($model,'dcierre',array('size'=>14,'maxlength'=>14,'readOnly'=>TRUE));
?>
</div>
</div>
<div class="row">
<div class="row-inline6">
<?php
$htmlOptions = array('style'=>'font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em');
echo $form->labelEx($model,'status');
?>
</div>
<div class="row-inline5">
<?php
$htmlOptions = 'text-transform: uppercase; font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em';
echo $form->DropDownList($model,'status',
array(
'ABIERTO'=>'ABIERTO',
'CERRADO'=>'CERRADO'
),
array('style'=> $htmlOptions,'width'=>'10'));
?>
</div>
</div>
<div class="row">
<div class="row-inline6">
<?php
$htmlOptions = array('style'=>'font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em');
echo $form->labelEx($model,'notas');
?>
</div>
<div class="row-inline5">
<?php
$htmlOptions = 'text-transform: uppercase; font-family: Helvetica Neue,Helvetica,Arial,sans-serif; font-size: 0.9em';
echo $form->textArea($model,'notas',array(
'rows'=>2,
'cols'=>40,
'maxlength'=>2000,
'placeholder'=>'Indique las observaciones',
'style'=> $htmlOptions,
));
?>
</div>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Crear',array("class"=>"row-button")); ?>
</div>
<div id="DialogDiv" align="center"></div>
<div class="row" align="center">
<?php
$dataProvider=new CActiveDataProvider('SqrMov' ,array(
'criteria'=>array(
'condition'=>'ordenid='.$model->ordenid,
),
'pagination'=>array(
'pageSize'=>5,
'pageVar'=>'page'
)
));
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'SqrMov-Grid-1',
'dataProvider' =>$dataProvider,
'columns' => array(
array(
'name'=>'sqrid',
'value'=>'$data->sqr_id->xsqr',
),
'dapertura',
'dcierre',
'user',
'notas',
'status',
array(
'class' => 'CButtonColumn',
'template' => '{update}',
'buttons' => array(
'update' => array(
'url'=>'Yii::app()->createUrl("operaciones/updateSqr", array("id"=>$data->idsqrmov))',
'options'=>array(
'ajax'=>array(
'type'=>'POST',
'url'=>"js:$(this).attr('href')",
'dataType'=>'html',
'click'=>'$("#modDialog").dialog("open");',
'update'=>'#DialogDiv',
)
)
),
)
),
),
)); ?>
</div>
In controller
/**
* Updates a particular model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id the ID of the model to be updated
*/
public function actionUpdateSqr($id)
{
$model=$this->loadModel($id,"sqr");
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['SqrMov']))
{
$model->attributes=$_POST['SqrMov'];
$usuario = Yii::app()->user->um->loadUserById(Yii::app()->user->id);
$model->usermod=$usuario->username;
$model->fecmod = date("Y-m-d H:i:s ");
if($model->save()){
Yii::app()->user->setFlash('success', "Modificado!");
$this->redirect(array('view','id'=>$model->idsqrmov));
}
}
// Yii::app()->clientScript->scriptMap['jquery.js'] = false;
// Yii::app()->clientScript->scriptMap['jquery.min.js'] = false;
// $this->renderPartial('editDialogSqr',array('model'=>$model,),false,true);
}