Code Duplication    Length = 16-18 lines in 2 locations

src/Form/Field/Select.php 1 location

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

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

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