I came into a problem with rendering widgets (with no IDs specified) on ajax-loaded views. Current strategy causes JS mess, becouse IDs like yw0, yw1 are repeated.
I suggest
moving ID autogeneration to widget factory, so I can easily change the way IDs are generated by making my own widget factory class
replacing widget counting numbers with random hash in default autogeneration
Yii generated unique IDs per requests that is typical case. If multiple requests are used to generate the page you should specify IDs yourself. If we’ll try to generate really unique IDs will be something like “yw550e8400-e29b-41d4-a716-446655440000”.
Nowadays ajax interface is a standard. Workaround of the issue is obvious, but the thing is to make life easier.
You don’t need to use GUID to achive small repeat probability, on the other hand this hash realy doesn’t mather, becouse nobody will directly use it in for example JS since it wasn’t specified by programmer. For appliaction yw0 or yw{whatever} is just the value.
Far more important then default autogeneration strategy is moving it to the place (widget factory for me is the best choice) developers can easily change it.
Recently I develop ajax-based interface application, so almost every request is ajax in my case. And i have to specify ID for every (even tiniest button) widget to keep the JS stable and consistent, otherwise it would throw yw0 stuff all over the DOM, making lots of difficult to debug mess. It’s a bit annoying.