Hi!
I use CGridView widget for listing some data. At the last column the three buttons are listed.
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'gallery-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'name',
array(
'class'=>'CButtonColumn',
'template' => '{update}{delete}{add}',
'buttons' => array(
'add'=>array(
'url'=>'Yii::app()->createUrl("/gallery/add", array("id" => $data->id))',
'imageUrl'=>Yii::app()->createUrl("/images/add.png"),
'click'=>'js:function() { $("#gallery-add").dialog("open"); $("#gallery-add-form-field-parent").val("' . $data->id . '"); return false; }',
),
),
),
),
)); ?>
As you can see at the Add button I call the open dialog for displaying the JuiDialog. In that dialog I have a form for ajax request:
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'gallery-add-form',
'enableAjaxValidation'=>true,
)); ?>
<?php echo $form->hiddenField($model,'parent', array('id'=>'gallery-add-form-field-parent')); ?>
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name', array('autocomplete'=>'off')); ?>
<?php echo $form->error($model,'name'); ?>
</div>
<?php echo CHtml::ajaxButton(
'Save',
Yii::app()->createUrl('ajax/index'),
array(
'type'=>'post',
'dataType'=>'json',
'beforeSend'=>'function() {
$("#resp").html("<img src=\"' . Yii::app()->createUrl('/images/loading.gif') . '\" />");
}',
'success'=>'function(resp){
alert('ok');
}',
),
array(
'type'=>'submit'
)
); ?>
<div id="resp"></div>
<?php $this->endWidget(); ?>
I need to pass into this form the Parent parameter for ajax sending. So I dont know how to pass $data->id into JuiDialog. $data->id works only in ‘url’ key of the buttons array, and in ‘click’ key it returns empty string.