@@ -110,6 +110,17 @@ class Sortable extends Widget
110
110
*/
111
111
public $ items = [];
112
112
113
+ /**
114
+ * @var bool disable items by default. This will be overwritten
115
+ * by the "disabled" set in individual [[items]].
116
+ */
117
+ public $ disabled = false ;
118
+
119
+ /**
120
+ * @var string css class to style disabled items.
121
+ */
122
+ public $ disabledClass = 'disabled ' ;
123
+
113
124
/**
114
125
* @var string the handle label, this is not HTML encoded. This will be overwritten
115
126
* by the "handleLabel" set in individual [[items]].
@@ -189,13 +200,13 @@ protected function initClientOptions()
189
200
{
190
201
if ($ this ->addHandle || $ this ->itemHasEnabledOption ('addHandle ' )) {
191
202
if (empty ($ this ->clientOptions ['handle ' ])) {
192
- $ this ->clientOptions ['handle ' ] = 'rubaxa-sortable-handle ' ;
203
+ $ this ->clientOptions ['handle ' ] = '. rubaxa-sortable-handle ' ;
193
204
}
194
205
}
195
206
196
- if ($ this ->itemHasEnabledOption ('disabled ' )) {
207
+ if ($ this ->disabled || $ this -> itemHasEnabledOption ('disabled ' )) {
197
208
if (empty ($ this ->clientOptions ['filter ' ])) {
198
- $ this ->clientOptions ['filter ' ] = 'rubaxa-sortable-disabled ' ;
209
+ $ this ->clientOptions ['filter ' ] = '. rubaxa-sortable-disabled ' ;
199
210
}
200
211
}
201
212
@@ -284,8 +295,8 @@ private function renderItems()
284
295
foreach ($ this ->items as $ item ) {
285
296
$ itemOptions = ArrayHelper::merge ($ this ->itemOptions , ArrayHelper::getValue ($ item , 'options ' , []));
286
297
287
- if (ArrayHelper::getValue ($ item , 'disabled ' , false )) {
288
- Html::addCssClass ($ itemOptions , $ this ->clientOptions ['filter ' ]);
298
+ if (ArrayHelper::getValue ($ item , 'disabled ' , $ this -> disabled )) {
299
+ Html::addCssClass ($ itemOptions , [ substr ( $ this ->clientOptions ['filter ' ], 1 ), $ this -> disabledClass ]);
289
300
}
290
301
291
302
switch ($ this ->type ) {
@@ -299,7 +310,7 @@ private function renderItems()
299
310
if ($ addHandle ) {
300
311
$ handleOptions = ArrayHelper::merge ($ this ->handleOptions , ArrayHelper::getValue ($ item , 'handleOptions ' , []));
301
312
302
- Html::addCssClass ($ handleOptions , $ this ->clientOptions ['handle ' ]);
313
+ Html::addCssClass ($ handleOptions , substr ( $ this ->clientOptions ['handle ' ], 1 ) );
303
314
304
315
$ handleElement = ArrayHelper::getValue ($ item , 'handleElement ' , $ this ->handleElement );
305
316
$ handleLabel = ArrayHelper::getValue ($ item , 'handleLabel ' , $ this ->handleLabel );
0 commit comments