| Conditions | 1 |
| Paths | 1 |
| Total Lines | 29 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | protected function registerClientScriptFor($selector) |
||
| 27 | { |
||
| 28 | $selector = Json::htmlEncode($selector); |
||
| 29 | |||
| 30 | $this->view->registerJs(<<<JS |
||
| 31 | $({$selector}).on('change', function (event) { |
||
| 32 | var similar = $(this).closest('form').find($selector), |
||
| 33 | value = $(this).val(); |
||
| 34 | |||
| 35 | if (this !== similar[0]) { |
||
| 36 | return; |
||
| 37 | } |
||
| 38 | |||
| 39 | if ($(this).data('field')) { |
||
| 40 | value = $(this).data('field').getData(); |
||
| 41 | var isCombo = true; |
||
| 42 | } |
||
| 43 | |||
| 44 | similar.slice(1).each(function() { |
||
| 45 | if (isCombo) { |
||
| 46 | $(this).data('field').setData(value, true); |
||
| 47 | } else { |
||
| 48 | $(this).val(value).trigger('change'); |
||
| 49 | } |
||
| 50 | }); |
||
| 51 | }); |
||
| 52 | JS |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | } |
||
| 56 |