Code Duplication    Length = 16-18 lines in 2 locations

src/Form/Field/Select.php 1 location

@@ 245-262 (lines=18) @@
242
     *
243
     * @return $this
244
     */
245
    protected function loadRemoteOptions($url, $parameters = [], $options = [])
246
    {
247
        $ajaxOptions = [
248
            'url' => $url.'?'.http_build_query($parameters),
249
        ];
250
251
        $ajaxOptions = json_encode(array_merge($ajaxOptions, $options));
252
253
        $this->script = <<<EOT
254
255
$.ajax($ajaxOptions).done(function(data) {
256
257
  var select = $("{$this->getElementClassSelector()}");
258
259
  select.select2({data: data});
260
  
261
  var value = select.data('value') + '';
262
  
263
  if (value) {
264
    value = value.split(',');
265
    select.select2('val', value);

src/Grid/Filter/Presenter/Select.php 1 location

@@ 144-159 (lines=16) @@
141
     *
142
     * @return $this
143
     */
144
    protected function loadRemoteOptions($url, $parameters = [], $options = [])
145
    {
146
        $ajaxOptions = [
147
            'url' => $url.'?'.http_build_query($parameters),
148
        ];
149
150
        $ajaxOptions = json_encode(array_merge($ajaxOptions, $options));
151
152
        $this->script = <<<EOT
153
154
$.ajax($ajaxOptions).done(function(data) {
155
  $(".{$this->getElementClass()}").select2({data: data});
156
});
157
158
EOT;
159
    }
160
161
    /**
162
     * Load options from ajax.