protected function getReplaceViewVars(FormView $view, array $options, $ajaxUrl, $routeName)
    {
        $allowClear = $options['required'] ? null : 'true';
        $allowClear = isset($options['select2']['allow_clear']) ? 'true' : $allowClear;

        return [
            'select2' => $this->skipNullValue([
                'wrapper_attr' => $options['select2']['wrapper_attr'],
                'placeholder' => isset($options['placeholder']) ? $options['placeholder'] : null,
                'width' => $options['select2']['width'],
                'allow_clear' => $allowClear,
                'template_result' => $options['select2']['template_result'],
                'template_selection' => $options['select2']['template_selection'],
                'dropdown_parent' => $options['select2']['dropdown_parent'],
                'selection_adapter' => $options['select2']['selection_adapter'],
                'data_adapter' => $options['select2']['data_adapter'],
                'dropdown_adapter' => $options['select2']['dropdown_adapter'],
                'results_adapter' => $options['select2']['results_adapter'],
                'matcher' => $options['select2']['matcher'],
                'create_tag' => $options['select2']['create_tag'],
                'close_on_select' => $options['select2']['close_on_select'],
                'min_results_for_search' => $options['select2']['min_results_for_search'],
                'min_input_length' => $options['select2']['min_input_length'],
                'max_input_length' => $options['select2']['max_input_length'],
                'max_selection_length' => $options['select2']['max_selection_length'],
                'data' => $options['select2']['data'],
                'tags' => $options['select2']['tags'] ? 'true' : null,
                'token_separators' => $options['select2']['token_separators'],
                'dir' => $options['select2']['dir'],
                'theme' => $options['select2']['theme'],
                'language' => strtolower(str_replace('_', '-', $options['select2']['language'])),
                'ajax' => [
                    'enabled' => $options['select2']['ajax'],
                    'url' => $ajaxUrl,
                    'data_type' => $options['select2']['ajax_data_type'],
                    'delay' => $options['select2']['ajax_delay'],
                    'cache' => $options['select2']['ajax_cache'] ? 'true' : null,
                    'data' => $options['select2']['ajax_data'],
                    'process_results' => $options['select2']['ajax_process_results'],
                    'transport' => $options['select2']['ajax_transport'],
                    'ajax_id' => null === $routeName ? $view->vars['id'] : null,
                    'page_size' => $options['select2']['ajax_page_size'],
                ],
            ]),
        ];
    }