diff core/includes/form.inc @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children af1871eacc83
line wrap: on
line diff
--- a/core/includes/form.inc	Tue Jul 10 15:07:59 2018 +0100
+++ b/core/includes/form.inc	Thu Feb 28 13:21:36 2019 +0000
@@ -235,13 +235,13 @@
  * @param array $variables
  *   An associative array containing:
  *   - element: An associative array containing the properties of the element.
- *     Properties used: #attributes, #children, #open,
- *     #description, #id, #title, #value, #optional.
+ *     Properties used: #attributes, #children, #description, #required,
+ *     #summary_attributes, #title, #value.
  */
 function template_preprocess_details(&$variables) {
   $element = $variables['element'];
   $variables['attributes'] = $element['#attributes'];
-  $variables['summary_attributes'] = new Attribute();
+  $variables['summary_attributes'] = new Attribute($element['#summary_attributes']);
   if (!empty($element['#title'])) {
     $variables['summary_attributes']['role'] = 'button';
     if (!empty($element['#attributes']['id'])) {
@@ -251,6 +251,11 @@
     $variables['summary_attributes']['aria-pressed'] = $variables['summary_attributes']['aria-expanded'];
   }
   $variables['title'] = (!empty($element['#title'])) ? $element['#title'] : '';
+  // If the element title is a string, wrap it a render array so that markup
+  // will not be escaped (but XSS-filtered).
+  if (is_string($variables['title']) && $variables['title'] !== '') {
+    $variables['title'] = ['#markup' => $variables['title']];
+  }
   $variables['description'] = (!empty($element['#description'])) ? $element['#description'] : '';
   $variables['children'] = (isset($element['#children'])) ? $element['#children'] : '';
   $variables['value'] = (isset($element['#value'])) ? $element['#value'] : '';
@@ -639,7 +644,7 @@
  *   else {
  *     $message = t('Finished with an error.');
  *   }
- *   drupal_set_message($message);
+ *   \Drupal::messenger()->addMessage($message);
  *   // Providing data for the redirected page is done through $_SESSION.
  *   foreach ($results as $result) {
  *     $items[] = t('Loaded node %title.', array('%title' => $result));
@@ -774,18 +779,18 @@
  * Form API takes care of batches that were set during form submission.
  *
  * @param \Drupal\Core\Url|string $redirect
- *   (optional) Either path or Url object to redirect to when the batch has
- *   finished processing. Note that to simply force a batch to (conditionally)
- *   redirect to a custom location after it is finished processing but to
- *   otherwise allow the standard form API batch handling to occur, it is not
- *   necessary to call batch_process() and use this parameter. Instead, make
- *   the batch 'finished' callback return an instance of
- *   \Symfony\Component\HttpFoundation\RedirectResponse, which will be used
+ *   (optional) Either a path or Url object to redirect to when the batch has
+ *   finished processing. For example, to redirect users to the home page, use
+ *   '<front>'. If you wish to allow standard form API batch handling to occur
+ *   and force the user to be redirected to a custom location after the batch
+ *   has finished processing, you do not need to use batch_process() and this
+ *   parameter. Instead, make the batch 'finished' callback return an instance
+ *   of \Symfony\Component\HttpFoundation\RedirectResponse, which will be used
  *   automatically by the standard batch processing pipeline (and which takes
- *   precedence over this parameter).
- *   User will be redirected to the page that started the batch if this argument
- *   is omitted and no redirect response was returned by the 'finished'
- *   callback. Any query arguments will be automatically persisted.
+ *   precedence over this parameter). If this parameter is omitted and no
+ *   redirect response was returned by the 'finished' callback, the user will
+ *   be redirected to the page that started the batch. Any query arguments will
+ *   be automatically persisted.
  * @param \Drupal\Core\Url $url
  *   (optional) URL of the batch processing page. Should only be used for
  *   separate scripts like update.php.