diff --git a/core/lib/Drupal/Core/Render/Element/Radio.php b/core/lib/Drupal/Core/Render/Element/Radio.php index 2e8b28c..8036952 100644 --- a/core/lib/Drupal/Core/Render/Element/Radio.php +++ b/core/lib/Drupal/Core/Render/Element/Radio.php @@ -61,8 +61,19 @@ public static function preRenderRadio($element) { $element['#attributes']['type'] = 'radio'; Element::setAttributes($element, array('id', 'name', '#return_value' => 'value')); - if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) { - $element['#attributes']['checked'] = 'checked'; + if (isset($element['#return_value']) && $element['#value'] !== FALSE) { + // To avoid auto-casting during '==' we convert int 0 to '0' for both operands. + // It will prevent wrong true-checking for both cases: 0 == 'string' and 'string' == 0. + if ($element['#value'] === 0) { + $element['#value'] = '0'; + } + if ($element['#return_value'] === 0) { + $element['#return_value'] = '0'; + } + + if ($element['#value'] == $element['#return_value']) { + $element['#attributes']['checked'] = 'checked'; + } } static::setAttributes($element, array('form-radio')); diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index d54a055..0f0897f 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -1706,7 +1706,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { break; case 'link_display': $form['#title'] .= $this->t('Which display to use for path'); - $options = array(FALSE => $this->t('None'), 'custom_url' => $this->t('Custom URL')); + $options = array('' => $this->t('None'), 'custom_url' => $this->t('Custom URL')); foreach ($this->view->storage->get('display') as $display_id => $display) { if ($this->view->displayHandlers->get($display_id)->hasPath()) { diff --git a/core/modules/views_ui/src/Tests/DisplayTest.php b/core/modules/views_ui/src/Tests/DisplayTest.php index 4fab7d8..c64eb81 100644 --- a/core/modules/views_ui/src/Tests/DisplayTest.php +++ b/core/modules/views_ui/src/Tests/DisplayTest.php @@ -168,7 +168,7 @@ public function testLinkDisplay() { $this->assertEqual($result[0], t('None'), 'Make sure that the link option summary shows "None" by default.'); $this->drupalGet($link_display_path); - $this->assertFieldChecked('edit-link-display-0'); + $this->assertFieldChecked('edit-link-display---'); // Test the default radio option on the link display form. $this->drupalPostForm($link_display_path, array('link_display' => 'page_1'), t('Apply'));