hello
Yii 1.1.14
I’m creating an application, I want to get a popup to select a year and then generate a reporting file corresponding to this selected year.
To test things before I had a fixed variable for the year and it worked fine.
Now I tried to use CJuiDialog to ask for the year.
Here’s the controller action :
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
));
}
}
And this is the view :
<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>
But this does not work :
The old link in div reportingtest does not work anymore (page not found at …/index.php?r=planning/xlsAbsences).
But the action xlsAbsences exists and has not changed.
The new link in div reporting does not work better - same error.
And here’s the most weird thing :
If in the view, I delete the line : <?php echo CHtml::DropDownList …
The old link works again.
But perhaps this is normal but please I need to understand whats happening !?
EDIT : I updatede source code …