Answer the question
In order to leave comments, you need to log in
How to correctly assign a value to a variable in a Yii controller?
Hey!
For example, we have this view.php:
<?php if ($this->beginCache('item', array(
'duration' => Yii::app()->params['cacheDuration'],
'dependency' => array(
'class' => 'system.caching.dependencies.CDbCacheDependency',
'sql' => 'SELECT MAX(update_time) FROM {{items}}'
),
))) { ?>
<?php $this->widget('AMListView', array(
'id' => 'items',
'dataProvider' => $dataProvider,
'pager' => array(
'class' => 'AMLinkPager',
),
)); ?>
<?php $this->endCache(); } ?>
public function run() {
$this->owner->owner->renderDynamic(array($this, "dynamic")); // Динамический рендер
}
public function dynamic() {
if ($this->owner && $this->owner->owner) {
$this->owner->owner->param = 'какое-то значение'; // !!!! вот этот параметр не ссетится в базовый контроллер (поведение) $this->owner->owner
print_r($this->owner->owner); // Но в дампе есть значение param!
}
// Какой-то код
return $str;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question