I have uploaded images into my project folder. But I cannot show it in the:
1. CGridVIew
Table
Can anyone teach me how to do it?? Thanks all
And this is my code in views/barang/admin
<?php
/* #var $this BarangController */
/* #var $model Barang */
$this->breadcrumbs=array(
'Barang'=>array('index'),
'Manajemen Barang',
);
$this->menu=array(
array('label'=>'Daftar Barang', 'url'=>array('index')),
array('label'=>'Tambah Data Barang', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('barang-grid', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1>Manajemen Barang</h1>
<p>Kalo mau nyari di kotak pencarian bisa dengan tambahin ini: (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b>, <b>=</b>) gan </p>
<?php echo CHtml::link('Pencarian Lanjut','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'barang-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id_barang',
'nama_barang',
'id_merk',
'harga',
'foto',
/*
'deskripsi',
*/
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Hi, I have enter the code of my admin.php in here. Is that you need to see? If no, I will update the controller and the model. Thanks
Try this edited version of your code.
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'barang-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id_barang',
'nama_barang',
'id_merk',
'harga',
array(
'type' => 'raw',
'value' => 'CHtml::image(Yii::app()->baseUrl . "/images/barang/" . $data->foto)'
),
array(
'class'=>'CButtonColumn',
),
),
)); ?>
echo CHtml::image(Yii::app()->baseUrl . "/images/barang/" . $data->foto',
"alt tag fo foo",
array("width"=>"150px" ,"height"=>"150px"));
Related
This seemed to be asked before but applying such answers did not gave me the solution. I have a create form which records the payments of the clients. It works just fine until I tried to transfer it inside a CJuiDialog in another view.
In my create.php:
<?php
/* #var $this PaymentsController */
/* #var $model Payments */
$this->breadcrumbs=array(
'Payments'=>array('index'),
'Create',
);
$this->menu=array(
array('label'=>'List Payments', 'url'=>array('index')),
array('label'=>'Manage Payments', 'url'=>array('admin')),
);
?>
<h4 class="text-success">Payments <span class="glyphicon glyphicon-tag"></span></h4>
<hr>
<?php $this->renderPartial('_form', array('model'=>$model)); ?>
And this is how i put the datetimepicker in my _form.php:
<div class="row">
<?php echo $form->labelEx($model,'payment_date'); ?>
<?php
$this->widget('EJuiDateTimePicker',array(
'model'=>$model, //Model object
'attribute'=>'payment_date', //attribute name
//'dateFormat'=>'dd-mm-yy',
'value'=>date('MM-dd-yy H:i:s'),
'mode'=>'datetime', //use "time","date" or "datetime" (default)
'language'=>'en-GB',
'options'=>array(
'dateFormat'=>'yy-mm-dd',
) // jquery plugin options
));
?>
<?php echo $form->error($model,'payment_date'); ?>
</div>
and in my actionCreate controller:
public function actionCreate($id, $bal)
{
$model=new Payments;
$model->contract_id = $id;
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
if(isset($_POST['Payments']))
{
$_POST['Payments']['remaining_balance'] = $bal - $_POST['Payments']['down_payment'];
$_POST['Payments']['paid_thru'] = $_POST['Payments']['account_id'];
$balance = $_POST['Payments']['remaining_balance'];
$model->attributes=$_POST['Payments'];
if($model->save())
{
$model->updateBalance($id, $balance);
$this->redirect(array('servicecontract/view','id'=>$id));
}
}
$this->renderPartial('create',array(
'model'=>$model, 'contr'=>$id,
),false, true);
}
and this is how I implement the CJuiDialog in my view.php:
<?php
echo CHtml::ajaxLink(
"Make Payments", //link label
Yii::app()->createUrl( 'tcfunecareModule/payments/create'),
array( // ajaxOptions
'type' => 'GET',
'success' => "function( data )
{
//alert( data );
$('#mydialog').dialog('open');
$('#dlg-content').html(data);
}",
'data' => array( 'id' => $model->contract_id, 'bal'=>$model->contract_balance)
),
array('class'=>'btn btn-info pull-right')
);
?>
<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id' => "mydialog",
'options' => array(
'autoOpen' => false,
'width' => 'auto',
'height' => 'auto',
//'show'=>'fade-in',
'hide'=>'fade',
'modal' => true,
'open'=> 'js:function(event, ui) { $(".ui-dialog-titlebar").hide(); }',
'buttons' => array(
Yii::t('app', 'Close') => 'js:function() {$(this).dialog("close");}',
),
)));
?>
<div id="dlg-content" style="dispay:none;"></div>
<?php
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>
The EJuiDateTimePicker works fine when create.php is being run in an entire page. But when I render it inside the CJuiDialog, it is not working. What should I do?
Hey in case someone will happen to encounter the same problem. I have here the solution. In your controller:
if (Yii::app()->request->isAjaxRequest) {
Yii::app()->clientScript->scriptMap['jquery.js'] = false;
yii::app()->clientScript->scriptMap['jquery-ui.min.js'] = false;
$this->renderPartial('create',array(
'model'=>$model,'contr_id'=>$id,
),false,true);}
Just set those two in false and you're good to go.
I have a category,And I need to create a subcategory of that.
When i tried to create the subcategory i have a field called category Name which should preloaded with the name of category which i wish to create subcategory.
how can i achieve this..
My controller
public function actionCreate($id)
{
$model=new SubCategory;
$mode = Category::model()->findAll();
$mode_1=$this->loadModel1($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['SubCategory']))
{
$model->attributes=$_POST['SubCategory'];
if($model->save())
$this->redirect(array('create','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
}
And the form
<?php
/* #var $this SubCategoryController */
/* #var $model SubCategory */
/* #var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'sub-category-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<?php
$category_id = $_GET['id'];
$category = Category::model()->findByAttributes(array('id' => $category_id));
// echo '<pre>';print_r($category);'</pre>';
?>
<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,'category_id'); ?>
<?php echo $form->textField($model,'category_id',
array('class'=>'form-control','style'=>'width:300px;')); ?>
<?php echo $form->error($model,'category_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'subcategory_name'); ?>
<?php echo $form->textField($model,'subcategory_name',array('class'=>'form-control','style'=>'width:300px;')); ?>
<?php echo $form->error($model,'subcategory_name'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array('class' => 'btn btn-default')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
<div style="width: 97%; margin: auto;" >
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'fav-category-grid',
'dataProvider'=>$model->search(),
//'filter'=>$model,
'columns'=>array(
// 'id',
//'favcategory',
array('header'=>'#','htmlOptions'=>array('width'=>'60px'),
'value'=>'$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)',
),
//'id',
//'category_id',
array(
'name' => 'category_id',
'value' => '$data->category->categoryname',
//'filter'=> CHtml::listData(Category::model()->findAll(array('order'=>'categoryname')), 'categoryid', 'categoryname')
),
'subcategory_name',
array(
'class' => 'CButtonColumn',
'htmlOptions'=>array('width'=>'110px'),
'template' => '{update}{delete}',
'buttons' => array(
'update'=>array(
'imageUrl' =>false,
'label' => '',
'options' => array('title'=>'update','class'=>'btn btn-info btn-xs fa fa-pencil-square-o'),
),
'delete'=>array(
'imageUrl' =>false,
'label' => 'delete',
'options' => array('title'=>'view','class'=>'btn btn-danger btn-xs'),
),
)
),
),
'itemsCssClass'=>'table table-striped table-bordered table-hover',
'pagerCssClass'=>'pagination',
'pager'=>array( 'header' => '','lastPageLabel'=>'<span class="glyphicon glyphicon-chevron-right"></span><span class="glyphicon glyphicon-chevron-right"></span>','firstPageLabel'=>'<span class="glyphicon glyphicon-chevron-left"></span><span class="glyphicon glyphicon-chevron-left"></span>','prevPageLabel'=>'<span class="glyphicon glyphicon-chevron-left"></span>','nextPageLabel'=>'<span class="glyphicon glyphicon-chevron-right"></span>','header' => '','cssFile' => Yii::app()->baseUrl . '/css/pager.css','htmlOptions'=>array('class'=>'pagination'),'selectedPageCssClass'=>'active'),
)); ?>
</div>
I can see category model $category getting loaded in the form.
$category = Category::model()->findByAttributes(array('id' => $category_id));
And if id in category table is primary key, then I suggest, just for simplicity:
$category = Category::model()->findByPk($category_id);
Now I am guessing you may want that in textField which will be disabled.
So use textField() of CActiveForm in the form, something like:
$form->textField($category, 'name', array('disabled' => 'disabled'));
textField docs
Note: The second parameter must be the attribute name, I have assumed name.
Also I don't see the use of the following two lines in actionCreate(). I mean, the variable $mode and $mode_1 are not used anywhere in that action.
$mode = Category::model()->findAll();
$mode_1=$this->loadModel1($id);
This is the view :
<?php
$this->renderPartial('_search', array(
'model' => $model
));
?>
This is the _search.php file:
<div class="wide form">
<?php
$form = $this->beginWidget('CActiveForm', array(
'action' => Yii::app()->createUrl($this->route),
'method'=>'get',
));
?>
<div class="row">
<?php echo $form->label($model,'month'); ?>
<?php echo $form->textField($model,'month'); ?>
</div>
<div class="row">
<?php echo $form->label($model,'year'); ?>
<?php echo $form->textField($model,'year'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Filter'); ?>
</div>
<?php $this->endWidget(); ?>
</div>
The controller index function :
$user_id = Yii::app()->user->attributes->id;
$dataProvider = new CActiveDataProvider('Salaries', array(
'criteria'=>array(
'order'=>'id DESC'
),
'pagination'=>array(
'pageSize'=>20,
),
));
$model = new Salaries();
$this->render('index',array(
'dataProvider' => $dataProvider,
'model' => $model
));
And the model:
public function search()
{
// #todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('first_name',$this->first_name,true);
$criteria->compare('last_name',$this->last_name,true);
$criteria->compare('month',$this->month);
$criteria->compare('year',$this->year);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
When I press the filter button the url is generated and it looks like:
/index?Salaries[month]=2&Salaries[year]=&yt0=Filter
but it does not do anything. I don't understand why . What am I doing wrong? thx
UPDATE THIS IS THE TABLE:
$this->widget('GridView', array(
'id' => 'my-grid',
'dataProvider' => $dataProvider,
// 'filter'=>$model,
'ajaxUpdate'=>false,
'columns' => array(
...............
),
));
1) Make sure you have enabled rules for search on filterable fields.
[model]
public function rules() {
return array(
'id, first_name, last_name, /*...*/', 'safe', 'on' => 'search',
);
}
2) Don't call CActiveDataProvider in controller (you are not passing any filtering data there, bdw), use model's search() method (put ordering and pagination params there too).
[controller]
$model = new Salaries('search'); //pass scenario!
/*
* Will assign any filtering attributes to model attributes,
* if there is no filtering attributes than empty array will be
* assigned for attributes (default value)
*/
$model->attributes = Yii::app()->request->getParam('Scenario', []);
[view]
$this->widget('GridView', array(
'id' => 'my-grid',
'dataProvider' => $model->search(), // Where your filtering will take effect.
'filter' => $model,
I am new to Yii. I have done a normal criteria search, and rendering them in the Grid view in Yii. If I click on the second page after searching/filtering, it again gives me the whole set of records in the Grid view.
My View:
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'nimsoft-alerts-form',
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
)); ?>
<h1>Missing Hosts List</h1>
<?php //echo $form->errorSummary($model); ?>
<div style="float:left;">
<div class="row">
<?php echo $form->labelEx($model,'host_start_date'); ?>
<?php
Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
$this->widget('CJuiDateTimePicker', array(
'attribute' => 'host_start_date',
'language' => '',
'model' => $model,
'options' => array(
'mode' => 'focus',
'dateFormat' => 'yy-mm-dd',
//'minDate'=>'0',
'showAnim' => 'slideDown',
),
'htmlOptions' => array(
'style'=>'height:20px;',
'value' => $model->host_start_date,
),
));
?>
<?php echo $form->error($model,'host_start_date'); ?>
</div>
</div>
<div style="float:left;"> </div>
<div style="float:left;">
<div class="row">
<?php echo $form->labelEx($model,'host_end_date'); ?>
<?php
Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
$this->widget('CJuiDateTimePicker', array(
'attribute' => 'host_end_date',
'language' => '',
'model' => $model,
'options' => array(
'mode' => 'focus',
'dateFormat' => 'yy-mm-dd',
//'minDate'=>'0',
'showAnim' => 'slideDown',
),
'htmlOptions' => array(
'style'=>'height:20px;',
'value' => $model->host_end_date,
),
));
?>
<?php echo $form->error($model,'host_end_date'); ?>
</div>
</div>
<div class="row buttons">
<?php echo CHtml::button('Search',array('submit' => array('Site/index')));?>
<?php echo CHtml::button('Search and Export',array('submit' => array('Site/Export')));?>
</div>
<?php $this->endWidget(); ?>
<!--<div class="row buttons">
<a href="<?php //echo $this->createUrl('Site/Index',array('id'=>$cust_id,'isXLSDownload'=>1));?>" title="Export For All Customers" class="btn btn-primary circle_ok" style="text-decoration: none; color:#FF3333;" ><b>Export All</b></a>
</div>-->
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'enableSorting' => false,
'columns'=>array(
array( // display 'create_time' using an expression
'name'=>'alert_device',
'value'=>'$data->alert_device',
),
array( // display 'create_time' using an expression
'name'=>'alert_event_time',
'value'=>'$data->alert_event_time',
),
array( // display 'create_time' using an expression
'name'=>'alert_datetime',
'value'=>'$data->alert_datetime',
),
),
//'itemView'=>'_view',
));
?>
</div>
My Action:
public function actionIndex()
{
//$this->layout=false;
$model=new NimsoftAlerts;
if(isset($_POST['NimsoftAlerts']))
{
$model->attributes=$_POST['NimsoftAlerts'];
if($model->validate())
{
$pagination=1;
$criteria = new CDbCriteria();
$criteria->condition = "alert_datetime >= '$model->host_start_date' and alert_datetime <= '$model->host_end_date' and alert_itsm_ack_status IS NULL";
$details = NimsoftAlerts::model()->findAll($criteria);
$dataProvider=new CActiveDataProvider('NimsoftAlerts',array(
'criteria' => $criteria,));
}
else $dataProvider=new CActiveDataProvider('NimsoftAlerts');
// if(isset($pagination))
// {
// $dataProvider=new CActiveDataProvider('NimsoftAlerts',array(
// 'criteria' => $criteria,));
// }
}
else
{ $dataProvider=new CActiveDataProvider('NimsoftAlerts'); }
if($_REQUEST['isXLSDownload']=='1')
{
$xlsName='Missing_Host_Details_'.date('YmdHis').'.xls';
$sheetName='Missing Host Details';
$headerTxt='Host Details';
$arrTh=array(
'alert_device'=>array('label'=>'Alert Device'),
'alert_event_time'=>array('label'=>'Alert Event Time'),
'alert_datetime'=>array('label'=>'Alert Datetime'),
);
$this->generateCXLS($xlsName,$sheetName,$criteria,$model,$headerTxt,$arrTh);
//GlobalFuncs::generateCXLS($xlsName,$sheetName,$criteria,$model,$headerTxt,$arrTh);
}
$nimsoftAlerts = new NimsoftAlerts;
$viewNimsoftTktSts = $nimsoftAlerts->dispNimsoftTktSts();
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
$this->render('index',array(
'viewNimsoftTktSts'=>$viewNimsoftTktSts,
'dataProvider'=>$dataProvider,
'model'=>$model,
));
}
On clicking the pagination buttons, this is what gets called -
$dataProvider=new CActiveDataProvider('NimsoftAlerts');
and not
if(isset($_POST['NimsoftAlerts'])) { [......] }.
So try this -
$model=new NimsoftAlerts;
$model->unsetAttributes(); // clear any default values
//Removed the content from here.
if(isset($_POST['NimsoftAlerts']))
{
$model->attributes=$_POST['NimsoftAlerts'];
if($model->validate())
{
[.....]
}
else {
$dataProvider = $model->search();
}
}
else {
$dataProvider = $model->search();
}
The $model->search() will add the filters and the pagination would include the filtered values received from $_GET[].
I hope it helps.
It seems that the selected dates from your custom search form does not get send when the pagination is used and so all records are fetched. So you have to send them manually.
I have implemented the same scenario in my sample project. Try to resemble it in your project.
In your view file -
//Your form has datepicker, this form has a textbox. On submit the values are posted to apply the filter.
<form id="filter_form" method="POST">
<input name="Skill[name]" id="Skill_name" value="<?php echo $model->name; ?>" />
<input type="submit" name="submit_btn" id="submit_btn" value="Submit" />
</form>
<script>
$(document).ready(function() {
$('.page a').click(function(ev) {
ev.preventDefault();
$.fn.yiiGridView.update('skill-grid', {data: $('#filter_form').serialize()}); //This will include the values from the form (dates in your case)
return false;
});
});
</script>
In your controller-action -
$model = new Skill;
$model->unsetAttributes();
if(isset($_REQUEST['Skill'])) {
$model->attributes = $_REQUEST['Skill'];
}
$dataProvider = $model->search();
$this->render('admin', array(
'dataProvider' => $dataProvider,
'model' => $model,
));`
Important Note: Replace the 'Skill' Model name with 'NimsoftAlerts'.
I hope it helps.
Q : how to get the checkbox value from cgridview?
Status : I create cgridview in a popbox with CJuiDialog. But I can't get the value of checkbox from grid view. I got 500 error.
This is my view to open the popup box
<div style="height:50px;">
<?php $imghtml=CHtml::image(Yii::app()->request->baseUrl.'/images/assets/approver.png','', array('style'=>'margin: 5px 0;')); ?>
<?php echo CHtml::ajaxLink(
Yii::t('accrecei',$imghtml),
$this->createUrl('implementer/Approverlist', array('id'=>$model->id)),
array(
'onclick'=>'$("#accreceilist").dialog("open"); return false;',
'update'=>'#reviewerlist'
),
array(
'id'=>'showaccreceilist',
'class'=>'btn btn-info',
'title'=>'Add/Remove reviewer',
'style'=>'width:25px; float:right; margin-button:20px;',)
);?>
<div id="reviewerlist"></div>
</div>
This is the popup box
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
'id'=>'reviewerlist',
'options'=>array(
'title'=>Yii::t('accrecei','Reviewer List'),
'autoOpen'=>true,
'modal'=>'true',
'width'=>'750',
'height'=>'500',
),
));
//echo $this->renderPartial('_listing', array('model'=>$model, 'acccategory'=>$acccategory,'job'=>$job)); ?>
<?php $this->renderPartial('_listing',array('model' => $model,'arr_reviewer' => $arr_reviewer, 'current_reviewers'=> $current_reviewers),false,true); ?>
<?php $this->endWidget('zii.widgets.jui.CJuiDialog');?>
This is the grid view "_listing.php"
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'job-form',
'enableAjaxValidation'=>true,
)); ?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'acc-recei-grid',
'dataProvider'=>$model->search_reviewerlist(),
'filter'=>$model,
'columns'=>array(
array(
'class' => 'CCheckBoxColumn',
'selectableRows' => 2,
'checkBoxHtmlOptions' => array(
'name' => 'userids[]',
),
'value'=>'$data->id',
//'checked'=>'(in_array($data->id, $current_reviewers) ? 1 : ""',
'checked'=>function($data, $row) use ($current_reviewers){
return in_array($data->id, $current_reviewers);
}
),
'username',
array(
'type'=>'raw',
'value'=>'$data->id',
//'filter'=>array('style'=>'visible:none'),
//'headerHtmlOptions'=>array('style'=>'width:0px; display:none; border:none; textdecoration:none'),
'htmlOptions'=>array('style'=>'display:none; border:none;', 'class'=>'user-id'),
//'header'=>false,
//'filter'=>false,
),
),
)); ?>
<div align="center">
<?php echo CHtml::ajaxSubmitButton(Yii::t('reviewer','Update'),Yii::app()->createUrl('implementer/updatereviewer',array('id'=>$model->id)),array('success'=>'js: function(data) {
$("#reviewerlist").dialog("close");
}'),array('id'=>'closeJobDialog')); ?>
</div>
<?php $this->endWidget(); ?>
This is my controller function to get the value of checkbox
public function actionUpdatereviewer()
{
var_dump($_POST['userids']);
echo 'debug';
echo $_GET['id'];
die;
}
Thank you for your any advice.
I got it by Myself
This my view
<div style="height:50px;">
<?php $imghtml=CHtml::image(Yii::app()->request->baseUrl.'/images/assets/approver.png','', array('style'=>'margin: 5px 0;')); ?>
<?php echo CHtml::ajaxLink(
Yii::t('customer_id',$imghtml),
$this->createUrl('implementer/approverlist', array('id'=>$model->id)),
array(
'onclick'=>'$("#reviewerlist").dialog("open"); return false;',
'update'=>'#reviewerlist'
),
array('id'=>'reviewer-link',
'class'=>'btn btn-info',
'title'=>'Add/Remove reviewer',
'style'=>'width:25px; float:right; margin-button:20px;',)
);?>
<div id="reviewerlist"></div>
</div>
This is _list.php (render from popup box as my question)
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'job-form',
'enableAjaxValidation'=>true,
)); ?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'acc-recei-grid',
'dataProvider'=>$model->search_reviewerlist(),
'filter'=>$model,
'columns'=>array(
array(
'class' => 'CCheckBoxColumn',
'selectableRows' => 2,
'checkBoxHtmlOptions' => array(
'name' => 'userids[]',
),
'value'=>'$data->id',
'checked'=>function($data, $row) use ($current_reviewers){
return in_array($data->id, $current_reviewers);
}
),
'username',
),
)); ?>
<div align="center">
<?php echo CHtml::ajaxSubmitButton(Yii::t('reviewer','Update'),Yii::app()->createUrl('implementer/updatereviewer',array('id'=>$model->id)),array('success'=>'js: function(data) {
$("#reviewerlist").dialog("close");
}'),array('id'=>'closeJobDialog')); ?>
</div>
<?php $this->endWidget(); ?>
This is my controller
public function actionApproverlist($id)
{
$users = new Users('reviewerlist');
//$users->scenario = "reviewerlist";
$users->unsetAttributes(); // clear any default values
if(isset($_GET['Users']))
$users->attributes=$_GET['Users'];
$model = $this->loadModel($id);
$arr_reviewer = Users::model()->get_reviewers();
$current_reviewers = explode( ',', $model->reviewers );
$reviewer_lastcomment = Yii::app()->generals->last_comment($model, $current_reviewers);
$this->renderPartial('listing',array('model' => $users, 'arr_reviewer' => $arr_reviewer, 'current_reviewers'=> $current_reviewers),false,true);
}
public function actionUpdatereviewer()
{
var_dump($_POST['userids']);
}
check $_POST['userids'] at your firebug->network. you will see the value of $_POST['userids'].
Let dance with yii. Cheeer!!!