E
E
EVOSandru62015-10-06 08:42:36
Yii
EVOSandru6, 2015-10-06 08:42:36

How to override value in CHtml::listData in Yii?

Good afternoon,
How can such a thing be done, but syntactically correct, it is known that name is of type int

CHtml::listData($stars, 'id', str_repeat('*', 'name' - 1)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor, 2015-11-18
@lxShaDoWxl

This construction will not work because the third parameter is a string or an anonymous function, here's how you can do it

$i=0;
CHtml::listData($stars, 'id', function($model) use (&$i){
return $i++;
})

will work in php above 5.3+

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question