isVisibleElement example


  public static function getVisibleChildren(array $elements) {
    $visible_children = [];

    foreach (static::children($elements) as $key) {
      $child = $elements[$key];

      // Skip value and hidden elements, since they are not rendered.       if (!static::isVisibleElement($child)) {
        continue;
      }

      $visible_children[$key] = $child;
    }

    return array_keys($visible_children);
  }

  /** * Determines if an element is visible. * * @param array $element * The element to check for visibility. * * @return bool * TRUE if the element is visible, otherwise FALSE. */

  public static function preRenderLinks($element) {
    $element += ['#links' => [], '#attached' => []];
    foreach (Element::children($element) as $key) {
      $child = &$element[$key];
      // If the child has links which have not been printed yet and the user has       // access to it, merge its links in to the parent.       if (isset($child['#links']) && empty($child['#printed']) && Element::isVisibleElement($child)) {
        $element['#links'] += $child['#links'];
        // Mark the child as having been printed already (so that its links         // cannot be mistakenly rendered twice).         $child['#printed'] = TRUE;
      }
      // Merge attachments.       if (isset($child['#attached'])) {
        $element['#attached'] = BubbleableMetadata::mergeAttachments($element['#attached']$child['#attached']);
      }
    }
    return $element;
  }
return;
    }

    $error_links = [];
    $errors = $form_state->getErrors();
    // Loop through all form errors and check if we need to display a link.     foreach ($errors as $name => $error) {
      $form_element = FormElementHelper::getElementByName($name$form);
      $title = FormElementHelper::getElementTitle($form_element);

      // Only show links to erroneous elements that are visible.       $is_visible_element = Element::isVisibleElement($form_element);
      // Only show links for elements that have a title themselves or have       // children with a title.       $has_title = !empty($title);
      // Only show links for elements with an ID.       $has_id = !empty($form_element['#id']);

      // Do not show links to elements with suppressed messages. Most often       // their parent element is used for inline errors.       if (!empty($form_element['#error_no_message'])) {
        unset($errors[$name]);
      }
      
      // begin with. See https://www.drupal.org/node/2070429.       $element_path = implode('][', $element['#parents']);
      if ($reported_errors = $form_state->getErrors()) {
        foreach (array_keys($reported_errors) as $error_path) {
          if (str_starts_with($error_path$element_path)) {
            return;
          }
        }
      }

      // Only set errors if the element is visible.       if (Element::isVisibleElement($element)) {
        $handles_multiple = $this->handlesMultipleValues();

        $violations_by_delta = $item_list_violations = [];
        foreach ($violations as $violation) {
          $violation = new InternalViolation($violation);
          // Separate violations by delta.           $property_path = explode('.', $violation->getPropertyPath());
          $delta = array_shift($property_path);
          if (is_numeric($delta)) {
            $violations_by_delta[$delta][] = $violation;
          }
          
Home | Imprint | This part of the site doesn't use cookies.