diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php b/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php index db9e4e9..82242b8 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php @@ -84,18 +84,26 @@ public function buildOptionsForm(&$form, &$form_state) { '#type' => 'checkboxes', '#title' => t('Accepted request formats'), '#description' => t('Request formats that will be allowed in responses. If none are selected all formats will be allowed.'), - '#options' => array_map('check_plain', $this->formats), + '#options' => $this->formats, '#default_value' => $this->options['formats'], ); } /** + * Overrides \Drupal\views\Plugin\views\PluginBase::submitOptionsForm(). + */ + public function submitOptionsForm(&$form, &$form_state) { + parent::submitOptionsForm($form, $form_state); + + $form_state['values']['style_options']['formats'] = array_filter($form_state['values']['style_options']['formats']); + } + + /** * Overrides \Drupal\views\Plugin\views\style\StylePluginBase::render(). */ public function render() { $rows = array(); $content_type = $this->displayHandler->getContentType(); - $formats = array_filter($this->options['formats']); if (empty($this->view->live_preview) && !empty($formats) && !in_array($content_type, $formats)) { // @todo throw exception? Alter the response for the view? diff --git a/core/modules/serialization/lib/Drupal/serialization/SerializationBundle.php b/core/modules/serialization/lib/Drupal/serialization/SerializationBundle.php index a2744b5..7e1527c 100644 --- a/core/modules/serialization/lib/Drupal/serialization/SerializationBundle.php +++ b/core/modules/serialization/lib/Drupal/serialization/SerializationBundle.php @@ -29,7 +29,7 @@ public function build(ContainerBuilder $container) { $container->register('serializer.normalizer.typed_data', 'Drupal\serialization\Normalizer\TypedDataNormalizer')->addTag('normalizer'); $container->register('serializer.encoder.json', 'Drupal\serialization\Encoder\JsonEncoder') - ->addTag('encoder', array('format' => array('json' => 'JSON'))); + ->addTag('encoder', array('format' => array('json' => 'JSON', 'ajax' => 'AJAX'))); $container->register('serializer.encoder.xml', 'Drupal\serialization\Encoder\XmlEncoder') ->addTag('encoder', array('format' => array('xml' => 'XML')));