Php Yii:使用Cjuidialog时出现奇怪错误
Yii 1.1.14 我正在创建一个应用程序,我想得到一个弹出窗口来选择一个年份,然后生成一个对应于这个选定年份的报告文件。 在这一年我有了一个固定的变量,它运行得很好之前,我需要测试一些东西 现在我试着用CJuiDialog来询问年份 以下是控制器操作:Php Yii:使用Cjuidialog时出现奇怪错误,php,yii,Php,Yii,Yii 1.1.14 我正在创建一个应用程序,我想得到一个弹出窗口来选择一个年份,然后生成一个对应于这个选定年份的报告文件。 在这一年我有了一个固定的变量,它运行得很好之前,我需要测试一些东西 现在我试着用CJuiDialog来询问年份 以下是控制器操作: public function actionReporting() { $years = array(); $yearstmp = Yii::app()->db->c
public function actionReporting()
{
$years = array();
$yearstmp = Yii::app()->db->createCommand("SELECT DISTINCT year FROM {{planning}} ORDER BY year")->queryAll();
foreach ($yearstmp as $yeartmp) {
$years[$yeartmp['year']] = $yeartmp['year'];
$lastyear = $yeartmp['year'];
}
if(isset($_POST['run'])) {
$this->actionXlsabsences($years[$_POST['year']]);
} else {
$this->render(
'reporting',
array(
'years'=>$years,
'lastyear'=>$lastyear
));
}
}
这是一种观点:
<div class="reportingtest">
<?php
$this->widget('zii.widgets.CMenu', array(
'items'=>array(
array('label'=>Yii::t('app','app.menu.reporting.planning.xlsabsence'), 'url'=>array('/planning/xlsAbsences')),
),
));
?>
</div>
<div class="reporting">
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
'id'=>'mydialog',
'options'=>array(
'title'=>Yii::t('app','reporting.xlsabsence'),
'autoOpen'=>false,
),
));
?>
<div class="well">
<?php echo CHtml::beginForm('','post'); ?>
<table class="contentheader">
<tr>
<th><?php echo Yii::t('app','reporting.select.year'); ?></th>
</tr>
<tr>
<td><?php echo CHtml::DropDownList('year', $lastyear, $years, array('options'=>array($lastyear=>array('selected'=>true)) )); ?></td>
</tr>
</table>
<br />
<?php echo CHtml::submitButton('Run', array('name' => 'run', 'class' => 'btn btn-success')); ?>
<?php echo CHtml::endForm(); ?>
</div>
<?php
$this->endWidget('zii.widgets.jui.CJuiDialog');
echo CHtml::link(Yii::t('app','app.menu.reporting.planning.xlsabsence'), '#', array(
'onclick'=>'$("#mydialog").dialog("open"); return false;',
));
?>
</div>
我也看到了我的代码中的一些错误——我做了更正并更新了上面发布的源代码
但是错误总是一样的(日志也是一样的)
当我在CHtml.php的第2325行之前引入var_dump($listData)时,我得到:
数组(2){[2013]=>string(4)“2013”[2014]=>string(4)“2014”}
如果我加载报告页面,在CHtml.php的第2325行之前添加“var_dump($listData);exit;”,该过程将继续进行,不会出现任何错误
我不明白那是怎么回事
编辑2: 我研究这个问题已经有一段时间了。 如果我不调用同一个控制器的另一个动作(就像我尝试做动作报告一样),一切都可以正常工作。 我真的需要帮助,因为我不明白为什么呼吁另一个行动是一个问题——我看过其他帖子,我觉得这就是解决问题的方法。
我还想知道为什么错误只出现在application.log上,而没有出现标准的yii错误页面。我发现了错误-我在调用的操作中使用了错误的呈现指令-不容易找到浏览器控制台中是否有javascript错误?检查下拉列表的ID,可能是id冲突的问题没有javascript错误-我已经尝试过更改id-结果相同
<?php echo CHtml::DropDownList ....
2014/02/04 21:26:02 [error] [php] Invalid argument supplied for foreach() (C:\wamp\www\yii01\framework\web\helpers\CHtml.php:2325)
Stack trace:
#0 C:\wamp\www\yii01\framework\web\CBaseController.php(126): require()
#1 C:\wamp\www\yii01\framework\web\CBaseController.php(95): PlanningController->renderInternal()
#2 C:\wamp\www\yii01\framework\web\CController.php(869): PlanningController->renderFile()
#3 C:\wamp\www\yii01\framework\web\CController.php(782): PlanningController->renderPartial()
#4 C:\wamp\www\yii02\yiiars02\protected\controllers\PlanningController.php(632): PlanningController->render()
#5 C:\wamp\www\yii02\yiiars02\protected\controllers\PlanningController.php(318): PlanningController->actionXlsAbsences()
#6 C:\wamp\www\yii01\framework\web\actions\CInlineAction.php(49): PlanningController->actionReporting()
#7 C:\wamp\www\yii01\framework\web\CController.php(308): CInlineAction->runWithParams()
#8 C:\wamp\www\yii01\framework\web\filters\CFilterChain.php(133): PlanningController->runAction()
#9 C:\wamp\www\yii01\framework\web\filters\CFilter.php(40): CFilterChain->run()
#10 C:\wamp\www\yii01\framework\web\CController.php(1145): CAccessControlFilter->filter()
#11 C:\wamp\www\yii01\framework\web\filters\CInlineFilter.php(58): PlanningController->filterAccessControl()
#12 C:\wamp\www\yii01\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter()
#13 C:\wamp\www\yii01\framework\web\CController.php(291): CFilterChain->run()
#14 C:\wamp\www\yii01\framework\web\CController.php(265): PlanningController->runActionWithFilters()
#15 C:\wamp\www\yii01\framework\web\CWebApplication.php(282): PlanningController->run()
#16 C:\wamp\www\yii01\framework\web\CWebApplication.php(141): CWebApplication->runController()
#17 C:\wamp\www\yii01\framework\base\CApplication.php(180): CWebApplication->processRequest()
#18 C:\wamp\www\yii02\yiiars02\index.php(13): CWebApplication->run()
REQUEST_URI=/yii02/yiiars02/index.php?r=planning/reporting
in C:\wamp\www\yii02\yiiars02\protected\views\planning\reporting.php (39)
in C:\wamp\www\yii02\yiiars02\protected\controllers\PlanningController.php (632)
in C:\wamp\www\yii02\yiiars02\protected\controllers\PlanningController.php (318)