Here is the question:
How do I show checkboxes in the view.php instead of 1 or 0 ?
These are the boolean fields:
‘scheduled_maintenance’,
‘unscheduled_maintenance’,
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'asset_id',
'type_of_maintenance',
'scheduled_maintenance',
'unscheduled_maintenance',
'schduled_date',
'completion_date',
'downtime',
'description_of_work',
array('label'=>'Company', 'value'=>$model->company->company_name),
),
)); ?>
aruna470
(Aruna470)
2
Maybe someone can elaborate on my code?
I am very nooby on this yet.
aruna470
(Aruna470)
4
Try this
<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
'id',
'asset_id',
'type_of_maintenance',
array('name'=>'scheduled_maintenance', 'value'=>$model->scheduled_maintenance?'Yes':'No'),
array('name'=>'unscheduled_maintenance', 'value'=>$model->unscheduled_maintenance?'Yes':'No'),
'schduled_date',
'completion_date',
'downtime',
'description_of_work',
array('label'=>'Company', 'value'=>$model->company->company_name),
),
)); ?>
Worked like a dream… Thank you…
What about the admin view?
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'pms-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'asset_id',
'type_of_maintenance',
'scheduled_maintenance',
'unscheduled_maintenance',
'schduled_date',
/*
'completion_date',
'downtime',
'description_of_work',
'company_id',
*/
array(
'class'=>'CButtonColumn',
),
),
)); ?>
If you don’t mind… I have the view down know and I will apply that to all my future checkboxes…
Here is the answer for anyone else searching for this:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'pms-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'asset_id',
'type_of_maintenance',
'scheduled_maintenance:boolean',
'unscheduled_maintenance:boolean',
'schduled_date',
/*
'completion_date',
'downtime',
'description_of_work',
'company_id',
*/
array(
'class'=>'CButtonColumn',
),
),
)); ?>
‘scheduled_maintenance:boolean’, <-- Adding boolean returns Yes/No instead of 0/1
And on the list view this is the solution aka _view.php:
<?php echo CHtml::checkBox('unscheduled_maintenance',$data->unscheduled_maintenance,$hmlOptions= array('disabled=>disabled')); ?>
Note the disabled attribute in the $htmlOptions doesn’t work. I have not found how to do this yet.