CButtonColumn buttons.url and buttons.visible

Hello guys. I can’t figure out why CButtonColumn buttons.url and buttons.visible use different sequence of arguments:




   ...

   'visible' => function($row, $data) { ... },

   'url'     => function($data, $row) { ... },

   ...



Is there some point of this sequence?

This is fixed in the trunk - http://code.google.com/p/yii/source/detail?r=3402

Thank you mdomba! But why $data is second argument? Does $row really used more then $data? To be honest I’ve never used $row.

different users has different thinking… for you is more important the $data field for someone other is the $row… so my answer is “why not” :D

The $row, $data order is the most used in all other cases that why I stick with it… and for me personally it makes sense… the row we are on… and the data for that row… but that is just my opinion :)

Well, I can’t find the situations where ‘visible’ or ‘url’ needs $row variable. I thought it’s used for css mostly. In any case now it’s better then it was. Thank you :)

There is an issue for the order of the parameters - http://code.google.com/p/yii/issues/detail?id=2892#c1

Thinking on reversing the order of parameters… opinions?

Necessarily, or earth will stop rotating. :)

See:

+my 5 cents from tracker:

+4 users starred issue.

This fix has been reverted as it breaks BC - http://code.google.com/p/yii/source/detail?r=3424

In the end we came to where we start :( You previous fix break BC a lot, because you change all signatures to ($row,$data).

How about change only CButtonColumn::buttons.visible? For usage:




visible' => function($data, $row) { ... },



I think that this is the best compromise between not fix and your previous fix.

creocoder

Please decide if to post on the issue or here as it’s difficult to follow the same discussion on different places.

I just responded you on the issue thread - http://code.google.com/p/yii/issues/detail?id=2892#c15

Looks like we come back to different sequence of arguments… Sometimes BC impedes progress …

mdomba, you said in Issue 2892 that very few (<= 1%) people use anonymous functions. The reason I use anonymous functions is for complex values. For example, I want to display a radio button list in a CDataColumn with CHtml::radioButtonList. Also, it is easier to debug the code, since Xdebug could break and step in the anonymous functions. For other simple values I stick with string. Do you have any professional suggestion for me? Do everybody only use simple values?

Thanks.

This thread is related to the parameter order problem… for other "problems" please open another threads so that we do not complicate this thread with different problems

anonymous functions are available from PHP 5.3 that is not so widespread that’s why my estimate of 1% (and by the forum questions regarding them, too)…

but I could be wrong :D

mdomba

Maybe it’s good idea to add poll to this thread?