You are here

abstract class YamlFormCompositeBase in YAML Form 8

Same name in this branch
  1. 8 src/Element/YamlFormCompositeBase.php \Drupal\yamlform\Element\YamlFormCompositeBase
  2. 8 src/Plugin/YamlFormElement/YamlFormCompositeBase.php \Drupal\yamlform\Plugin\YamlFormElement\YamlFormCompositeBase

Provides a base for composite elements.

Hierarchy

Expanded class hierarchy of YamlFormCompositeBase

File

src/Plugin/YamlFormElement/YamlFormCompositeBase.php, line 18

Namespace

Drupal\yamlform\Plugin\YamlFormElement
View source
abstract class YamlFormCompositeBase extends YamlFormElementBase {

  /**
   * {@inheritdoc}
   */
  public function getRelatedTypes(array $element) {
    return [];
  }

  /**
   * Get composite elements.
   *
   * @return array
   *   An array of composite elements.
   */
  protected abstract function getCompositeElements();

  /**
   * Get initialized composite element.
   *
   * @param array &$element
   *   A composite element.
   *
   * @return array
   *   The initialized composite test element.
   */
  protected abstract function getInitializedCompositeElement(array &$element);

  /**
   * {@inheritdoc}
   */
  public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
    parent::prepare($element, $yamlform_submission);

    // If #flexbox is not set or an empty string, determine if the
    // form is using a flexbox layout.
    if (!isset($element['#flexbox']) || $element['#flexbox'] === '') {
      $yamlform = $yamlform_submission
        ->getYamlForm();
      $element['#flexbox'] = $yamlform
        ->hasFlexboxLayout();
    }
  }

  /**
   * Format composite element value into lines of text.
   *
   * @param array $element
   *   A composite element.
   * @param array $value
   *   Composite element values.
   *
   * @return array
   *   Composite element values converted into lines of text.
   */
  protected function formatLines(array $element, array $value) {
    $items = [];
    $composite_elements = $this
      ->getInitializedCompositeElement($element);
    foreach (RenderElement::children($composite_elements) as $composite_key) {
      if (isset($value[$composite_key]) && $value[$composite_key] != '') {
        $composite_element = $composite_elements[$composite_key];
        $composite_title = $composite_element['#title'];
        $composite_value = $value[$composite_key];
        $items[$composite_key] = "<b>{$composite_title}:</b> {$composite_value}";
      }
    }
    return $items;
  }

  /**
   * {@inheritdoc}
   */
  public function getDefaultProperties() {
    $properties = [
      'title' => '',
      // General settings.
      'description' => '',
      'default_value' => [],
      // Form display.
      'title_display' => 'invisible',
      'description_display' => '',
      // Form validation.
      'required' => FALSE,
      // Flex box.
      'flexbox' => '',
    ] + $this
      ->getDefaultBaseProperties();
    $composite_elements = $this
      ->getCompositeElements();
    foreach ($composite_elements as $composite_key => $composite_element) {

      // Get #type, #title, and #option from composite elements.
      foreach ($composite_element as $composite_property_key => $composite_property_value) {
        if (in_array($composite_property_key, [
          '#type',
          '#title',
          '#options',
        ])) {
          $property_key = str_replace('#', $composite_key . '__', $composite_property_key);
          if ($composite_property_value instanceof TranslatableMarkup) {
            $properties[$property_key] = (string) $composite_property_value;
          }
          else {
            $properties[$property_key] = $composite_property_value;
          }
        }
      }
      if (isset($properties[$composite_key . '__type'])) {
        $properties['default_value'][$composite_key] = '';
        $properties[$composite_key . '__description'] = FALSE;
        $properties[$composite_key . '__required'] = FALSE;
        $properties[$composite_key . '__placeholder'] = '';
      }
      $properties[$composite_key . '__access'] = TRUE;
    }
    return $properties;
  }

  /**
   * {@inheritdoc}
   */
  public function getTableColumn(array $element) {
    $key = $element['#yamlform_key'];
    $title = $element['#title'] ?: $key;
    $is_title_displayed = YamlFormElementHelper::isTitleDisplayed($element);

    // Get the main composite element, which can't be sorted.
    $columns = parent::getTableColumn($element);
    $columns['element__' . $key]['sort'] = FALSE;

    // Get individual composite elements.
    $composite_elements = $this
      ->getInitializedCompositeElement($element);
    foreach (RenderElement::children($composite_elements) as $composite_key) {
      $composite_element = $composite_elements[$composite_key];

      // Make sure the composite element is visible.
      $access_key = '#' . $composite_key . '__access';
      if (isset($element[$access_key]) && $element[$access_key] === FALSE) {
        continue;
      }

      // Add reference to initialized composite element so that it can be
      // used by ::formatTableColumn().
      $columns['element__' . $key . '__' . $composite_key] = [
        'title' => ($is_title_displayed ? $title . ': ' : '') . (!empty($composite_element['#title']) ? $composite_element['#title'] : $composite_key),
        'sort' => TRUE,
        'default' => FALSE,
        'key' => $key,
        'element' => $element,
        'property_name' => $composite_key,
        'composite_key' => $composite_key,
        'composite_element' => $composite_element,
        'plugin' => $this,
      ];
    }
    return $columns;
  }

  /**
   * {@inheritdoc}
   */
  public function formatTableColumn(array $element, $value, array $options = []) {
    if (isset($options['composite_key']) && isset($options['composite_element'])) {
      $composite_key = $options['composite_key'];
      $composite_element = $options['composite_element'];
      $composite_value = $value[$composite_key];
      $composite_options = [];
      return $this->elementManager
        ->invokeMethod('formatHtml', $composite_element, $composite_value, $composite_options);
    }
    else {
      return $this
        ->formatHtml($element, $value);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getElementSelectorOptions(array $element) {
    $title = $this
      ->getAdminLabel($element) . ' [' . $this
      ->getPluginLabel() . ']';
    $name = $element['#yamlform_key'];
    $selectors = [];
    $composite_elements = $this
      ->getInitializedCompositeElement($element);
    foreach ($composite_elements as $composite_key => $composite_element) {
      $has_access = !isset($composite_elements['#access']) || $composite_elements['#access'];
      if ($has_access && isset($composite_element['#type'])) {
        $element_handler = $this->elementManager
          ->getElementInstance($composite_element);
        $composite_title = isset($composite_element['#title']) ? $composite_element['#title'] : $composite_key;
        switch ($composite_element['#type']) {
          case 'label':
          case 'yamlform_message':
            break;
          case 'yamlform_select_other':
            $selectors[":input[name=\"{$name}[{$composite_key}][select]\"]"] = $composite_title . ' [' . $this
              ->t('Select') . ']';
            $selectors[":input[name=\"{$name}[{$composite_key}][other]\"]"] = $composite_title . ' [' . $this
              ->t('Textfield') . ']';
            break;
          default:
            $selectors[":input[name=\"{$name}[{$composite_key}]\"]"] = $composite_title . ' [' . $element_handler
              ->getPluginLabel() . ']';
            break;
        }
      }
    }
    return [
      $title => $selectors,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);

    // Update #default_value description.
    $form['general']['default_value']['#description'] = $this
      ->t("The default value of the composite form element as YAML.");

    // Update #required label.
    $form['validation']['required']['#description'] .= '<br/>' . $this
      ->t("Checking this option only displays the required indicator next to this element's label. Please chose which elements should be required below.");
    $form['composite'] = [
      '#type' => 'fieldset',
      '#title' => $this
        ->t('@title settings', [
        '@title' => $this
          ->getPluginLabel(),
      ]),
    ];
    $form['composite']['elements'] = $this
      ->buildCompositeElementsTable();
    $form['composite']['flexbox'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Use Flexbox'),
      '#description' => $this
        ->t("If 'Automatic' is selected Flexbox layout will only be used if a Flexbox element is included in the form."),
      '#options' => [
        '' => $this
          ->t('Automatic'),
        0 => $this
          ->t('No'),
        1 => $this
          ->t('Yes'),
      ],
    ];
    return $form;
  }

  /**
   * Build the composite elements settings table.
   *
   * @return array
   *   A renderable array container the composite elements settings table.
   */
  protected function buildCompositeElementsTable() {
    $header = [
      $this
        ->t('Key'),
      $this
        ->t('Title/Description/Placeholder'),
      $this
        ->t('Type/Options'),
      $this
        ->t('Required'),
      $this
        ->t('Visible'),
    ];
    $rows = [];
    $composite_elements = $this
      ->getCompositeElements();
    foreach ($composite_elements as $composite_key => $composite_element) {
      $title = isset($composite_element['#title']) ? $composite_element['#title'] : $composite_key;
      $type = isset($composite_element['#type']) ? $composite_element['#type'] : NULL;
      $t_args = [
        '@title' => $title,
      ];
      $attributes = [
        'style' => 'width: 100%; margin-bottom: 5px',
      ];
      $state_disabled = [
        'disabled' => [
          ':input[name="properties[' . $composite_key . '__access]"]' => [
            'checked' => FALSE,
          ],
        ],
      ];
      $row = [];

      // Key.
      $row[$composite_key . '__key'] = [
        '#markup' => $composite_key,
        '#access' => TRUE,
      ];

      // Title, placeholder, and description.
      if ($type) {
        $row['title_and_description'] = [
          'data' => [
            $composite_key . '__title' => [
              '#type' => 'textfield',
              '#title' => $this
                ->t('@title title', $t_args),
              '#title_display' => 'invisible',
              '#placeholder' => $this
                ->t('Enter title...'),
              '#attributes' => $attributes,
              '#states' => $state_disabled,
            ],
            $composite_key . '__placeholder' => [
              '#type' => 'textfield',
              '#title' => $this
                ->t('@title placeholder', $t_args),
              '#title_display' => 'invisible',
              '#placeholder' => $this
                ->t('Enter placeholder...'),
              '#attributes' => $attributes,
              '#states' => $state_disabled,
            ],
            $composite_key . '__description' => [
              '#type' => 'textarea',
              '#title' => $this
                ->t('@title description', $t_args),
              '#title_display' => 'invisible',
              '#rows' => 2,
              '#placeholder' => $this
                ->t('Enter description...'),
              '#attributes' => $attributes,
              '#states' => $state_disabled,
            ],
          ],
        ];
      }
      else {
        $row['title_and_description'] = [
          'data' => [
            '',
          ],
        ];
      }

      // Type and options.
      // Using if/else instead of switch/case because of complex conditions.
      $row['type_and_options'] = [];
      if ($type == 'tel') {
        $row['type_and_options']['data'][$composite_key . '__type'] = [
          '#type' => 'select',
          '#required' => TRUE,
          '#options' => [
            'tel' => $this
              ->t('Telephone'),
            'textfield' => $this
              ->t('Text field'),
          ],
          '#attributes' => [
            'style' => 'width: 100%; margin-bottom: 5px',
          ],
          '#states' => $state_disabled,
        ];
      }
      elseif ($type == 'select' && ($composite_options = $this
        ->getCompositeElementOptions($composite_key))) {
        $row['type_and_options']['data'][$composite_key . '__type'] = [
          '#type' => 'select',
          '#required' => TRUE,
          '#options' => [
            'select' => $this
              ->t('Select'),
            'yamlform_select_other' => $this
              ->t('Select other'),
            'textfield' => $this
              ->t('Text field'),
          ],
          '#attributes' => [
            'style' => 'width: 100%; margin-bottom: 5px',
          ],
          '#states' => $state_disabled,
        ];
        $row['type_and_options']['data'][$composite_key . '__options'] = [
          '#type' => 'select',
          '#options' => $composite_options,
          '#required' => TRUE,
          '#attributes' => [
            'style' => 'width: 100%;',
          ],
          '#states' => $state_disabled + [
            'invisible' => [
              ':input[name="properties[' . $composite_key . '__type]"]' => [
                'value' => 'textfield',
              ],
            ],
          ],
        ];
      }
      else {
        $row['type_and_options']['data'][$composite_key . '__type'] = [
          '#type' => 'textfield',
          '#access' => FALSE,
        ];
        $row['type_and_options']['data']['markup'] = [
          '#markup' => $this->elementManager
            ->getElementInstance($composite_element)
            ->getPluginLabel(),
          '#access' => TRUE,
        ];
      }

      // Required.
      if ($type) {
        $row[$composite_key . '__required'] = [
          '#type' => 'checkbox',
          '#return_value' => TRUE,
        ];
      }
      else {
        $row[$composite_key . '__required'] = [
          'data' => [
            '',
          ],
        ];
      }

      // Access.
      $row[$composite_key . '__access'] = [
        '#type' => 'checkbox',
        '#return_value' => TRUE,
      ];
      $rows[$composite_key] = $row;
    }
    return [
      '#type' => 'table',
      '#header' => $header,
    ] + $rows;
  }

  /**
   * {@inheritdoc}
   */
  public function isMultiline(array $element) {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function formatHtml(array &$element, $value, array $options = []) {

    // Return empty value.
    if (empty($value) || empty(array_filter($value))) {
      return '';
    }
    $format = $this
      ->getFormat($element);
    switch ($format) {
      case 'list':
        $items = [];
        $composite_elements = $this
          ->getInitializedCompositeElement($element);
        foreach (RenderElement::children($composite_elements) as $composite_key) {
          $composite_element = $composite_elements[$composite_key];
          $composite_title = isset($composite_element['#title']) ? $composite_element['#title'] : $composite_key;
          $composite_value = isset($value[$composite_key]) ? $value[$composite_key] : '';
          if ($composite_value !== '') {
            $items[$composite_key] = [
              '#markup' => "<b>{$composite_title}:</b> {$composite_value}",
            ];
          }
        }
        return [
          '#theme' => 'item_list',
          '#items' => $items,
        ];
      case 'raw':
        $items = [];
        $composite_elements = $this
          ->getInitializedCompositeElement($element);
        foreach (RenderElement::children($composite_elements) as $composite_key) {
          $composite_value = isset($value[$composite_key]) ? $value[$composite_key] : '';
          if ($composite_value !== '') {
            $items[$composite_key] = [
              '#markup' => "<b>{$composite_key}:</b> {$composite_value}",
            ];
          }
        }
        return [
          '#theme' => 'item_list',
          '#items' => $items,
        ];
      default:
        $lines = $this
          ->formatLines($element, $value);
        foreach ($lines as $key => $line) {
          if ($key == 'email') {
            $lines[$key] = [
              '#type' => 'link',
              '#title' => $line,
              '#url' => \Drupal::pathValidator()
                ->getUrlIfValid('mailto:' . $line),
            ];
          }
          else {
            $lines[$key] = [
              '#markup' => $line,
            ];
          }
          $lines[$key]['#suffix'] = '<br/>';
        }
        return $lines;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getFormats() {
    return parent::getFormats() + [
      'list' => $this
        ->t('List'),
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function formatText(array &$element, $value, array $options = []) {

    // Return empty value.
    if (empty($value) || is_array($value) && empty(array_filter($value))) {
      return '';
    }
    $format = $this
      ->getFormat($element);
    switch ($format) {
      case 'list':
        $items = [];
        $composite_elements = $this
          ->getInitializedCompositeElement($element);
        foreach (RenderElement::children($composite_elements) as $composite_key) {
          $composite_element = $composite_elements[$composite_key];
          $composite_title = $composite_element['#title'];
          $composite_value = $value[$composite_key];
          if ($composite_value !== '') {
            $items[$composite_key] = "{$composite_title}: {$composite_value}";
          }
        }
        return implode("\n", $items);
      case 'raw':
        $items = [];
        $composite_elements = $this
          ->getInitializedCompositeElement($element);
        foreach (RenderElement::children($composite_elements) as $composite_key) {
          $composite_value = $value[$composite_key];
          if ($composite_value !== '') {
            $items[$composite_key] = "{$composite_key}: {$composite_value}";
          }
        }
        return implode("\n", $items);
      default:
        $lines = $this
          ->formatLines($element, $value);
        return implode("\n", $lines);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getExportDefaultOptions() {
    return [
      'composite_element_item_format' => 'label',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildExportOptionsForm(array &$form, FormStateInterface $form_state, array $export_options) {
    $form['composite'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Composite element'),
      '#open' => TRUE,
      '#weight' => -10,
    ];
    $form['composite']['composite_element_item_format'] = [
      '#type' => 'radios',
      '#title' => $this
        ->t('Composite element item format'),
      '#options' => [
        'label' => $this
          ->t('Option labels, the human-readable value (label)'),
        'key' => $this
          ->t('Option values, the raw value stored in the database (key)'),
      ],
      '#default_value' => $export_options['composite_element_item_format'],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildExportHeader(array $element, array $options) {
    $composite_elements = $this
      ->getInitializedCompositeElement($element);
    $header = [];
    foreach (RenderElement::children($composite_elements) as $composite_key) {
      $composite_element = $composite_elements[$composite_key];
      if (isset($composite_element['#access']) && $composite_element['#access'] === FALSE) {
        continue;
      }
      if ($options['header_format'] == 'label' && !empty($composite_element['#title'])) {
        $header[] = $composite_element['#title'];
      }
      else {
        $header[] = $composite_key;
      }
    }
    return $this
      ->prefixExportHeader($header, $element, $options);
  }

  /**
   * {@inheritdoc}
   */
  public function buildExportRecord(array $element, $value, array $export_options) {
    $record = [];
    $composite_elements = $this
      ->getInitializedCompositeElement($element);
    foreach (RenderElement::children($composite_elements) as $composite_key) {
      $composite_element = $composite_elements[$composite_key];
      if (isset($composite_element['#access']) && $composite_element['#access'] === FALSE) {
        continue;
      }
      if ($export_options['composite_element_item_format'] == 'label' && $composite_element['#type'] != 'textfield' && !empty($composite_element['#options'])) {
        $record[] = YamlFormOptionsHelper::getOptionText($value[$composite_key], $composite_element['#options']);
      }
      else {
        $record[] = isset($value[$composite_key]) ? $value[$composite_key] : NULL;
      }
    }
    return $record;
  }

  /**
   * {@inheritdoc}
   */
  public function getTestValue(array $element, YamlFormInterface $yamlform) {

    /** @var \Drupal\yamlform\YamlFormSubmissionGenerateInterface $generate */
    $generate = \Drupal::service('yamlform_submission.generate');
    $value = [];
    $composite_elements = $this
      ->getInitializedCompositeElement($element);
    foreach (RenderElement::children($composite_elements) as $composite_key) {
      $value[$composite_key] = $generate
        ->getTestValue($yamlform, $composite_key, $composite_elements[$composite_key]);
    }
    return [
      $value,
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getConfigurationFormProperties(array &$form, FormStateInterface $form_state) {
    $properties = parent::getConfigurationFormProperties($form, $form_state);
    foreach ($properties as $key => $value) {

      // Convert composite element access and required to boolean value.
      if (strpos($key, '__access') || strpos($key, '__required')) {
        $properties[$key] = (bool) $value;
      }

      // If the entire element is required remove required property for
      // composite elements.
      if (!empty($properties['required']) && strpos($key, '__required')) {
        unset($properties[$key]);
      }
    }
    return $properties;
  }

  /**
   * Get form option keys for composite element based on the composite element's key.
   *
   * @param string $composite_key
   *   A composite element's key.
   *
   * @return array
   *   An array form options.
   */
  protected function getCompositeElementOptions($composite_key) {

    /** @var \Drupal\yamlform\YamlFormOptionsInterface[] $yamlform_options */
    $yamlform_options = YamlFormOptions::loadMultiple();
    $options = [];
    foreach ($yamlform_options as $key => $yamlform_option) {
      if (strpos($key, $composite_key) === 0) {
        $options[$key] = $yamlform_option
          ->label();
      }
    }
    return $options;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
YamlFormCompositeBase::buildCompositeElementsTable protected function Build the composite elements settings table. 1
YamlFormCompositeBase::buildExportHeader public function Build an element's export header. Overrides YamlFormElementBase::buildExportHeader
YamlFormCompositeBase::buildExportOptionsForm public function Get an element's export options form. Overrides YamlFormElementBase::buildExportOptionsForm
YamlFormCompositeBase::buildExportRecord public function Build an element's export row. Overrides YamlFormElementBase::buildExportRecord
YamlFormCompositeBase::form public function Gets the actual configuration form array to be built. Overrides YamlFormElementBase::form 1
YamlFormCompositeBase::formatHtml public function Format an element's value as HTML. Overrides YamlFormElementBase::formatHtml
YamlFormCompositeBase::formatLines protected function Format composite element value into lines of text. 2
YamlFormCompositeBase::formatTableColumn public function Format an element's table column value. Overrides YamlFormElementBase::formatTableColumn
YamlFormCompositeBase::formatText public function Format an element's value as plain text. Overrides YamlFormElementBase::formatText
YamlFormCompositeBase::getCompositeElementOptions protected function Get form option keys for composite element based on the composite element's key.
YamlFormCompositeBase::getCompositeElements abstract protected function Get composite elements.
YamlFormCompositeBase::getConfigurationFormProperties public function Get an associative array of element properties from configuration form. Overrides YamlFormElementBase::getConfigurationFormProperties
YamlFormCompositeBase::getDefaultProperties public function Only a few elements don't inherit these default properties. Overrides YamlFormElementBase::getDefaultProperties 2
YamlFormCompositeBase::getElementSelectorOptions public function Get an element's selectors as options. Overrides YamlFormElementBase::getElementSelectorOptions
YamlFormCompositeBase::getExportDefaultOptions public function Get an element's default export options. Overrides YamlFormElementBase::getExportDefaultOptions
YamlFormCompositeBase::getFormats public function Get an element's available formats. Overrides YamlFormElementBase::getFormats
YamlFormCompositeBase::getInitializedCompositeElement abstract protected function Get initialized composite element. 4
YamlFormCompositeBase::getRelatedTypes public function Get related element types. Overrides YamlFormElementBase::getRelatedTypes
YamlFormCompositeBase::getTableColumn public function Get element's table column(s) settings. Overrides YamlFormElementBase::getTableColumn
YamlFormCompositeBase::getTestValue public function Get test value for an element. Overrides YamlFormElementBase::getTestValue 1
YamlFormCompositeBase::isMultiline public function Checks if element value could contain multiple lines. Overrides YamlFormElementBase::isMultiline
YamlFormCompositeBase::prepare public function Prepare an element to be rendered within a form. Overrides YamlFormElementBase::prepare 1
YamlFormElementBase::$configFactory protected property The configuration factory.
YamlFormElementBase::$currentUser protected property The current user.
YamlFormElementBase::$elementInfo protected property A element info manager.
YamlFormElementBase::$elementManager protected property The form element manager.
YamlFormElementBase::$entityTypeManager protected property The entity type manager.
YamlFormElementBase::$logger protected property A logger instance.
YamlFormElementBase::$tokenManager protected property The token manager.
YamlFormElementBase::build protected function Build an element as text or HTML. 2
YamlFormElementBase::buildConfigurationForm public function Form constructor. Overrides PluginFormInterface::buildConfigurationForm 1
YamlFormElementBase::buildHtml public function Build an element as HTML element. Overrides YamlFormElementInterface::buildHtml 1
YamlFormElementBase::buildText public function Build an element as text element. Overrides YamlFormElementInterface::buildText 1
YamlFormElementBase::checkAccessRules public function Check element access (rules). Overrides YamlFormElementInterface::checkAccessRules
YamlFormElementBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
YamlFormElementBase::displayDisabledWarning public function Display element disabled warning. Overrides YamlFormElementInterface::displayDisabledWarning 1
YamlFormElementBase::getAdminLabel public function Get an element's admin label (#admin_title, #title or #yamlform_key). Overrides YamlFormElementInterface::getAdminLabel
YamlFormElementBase::getConfigurationFormProperty protected function Get configuration property value. 1
YamlFormElementBase::getDefaultBaseProperties protected function Get default base properties used by all elements.
YamlFormElementBase::getDefaultFormat public function Get an element's default format name. Overrides YamlFormElementInterface::getDefaultFormat 17
YamlFormElementBase::getElementSelectorInputsOptions protected function Get an element's (sub)inputs selectors as options. 7
YamlFormElementBase::getElementStateOptions public function Get an element's supported states as options. Overrides YamlFormElementInterface::getElementStateOptions
YamlFormElementBase::getFormat public function Get element's format name by looking for '#format' property, global settings, and finally default settings. Overrides YamlFormElementInterface::getFormat 1
YamlFormElementBase::getInfo public function Retrieves the default properties for the defined element type. Overrides YamlFormElementInterface::getInfo
YamlFormElementBase::getKey public function Get an element's key/name. Overrides YamlFormElementInterface::getKey
YamlFormElementBase::getLabel public function Get an element's label (#title or #yamlform_key). Overrides YamlFormElementInterface::getLabel
YamlFormElementBase::getPluginApiLink public function Get link to element's API documentation. Overrides YamlFormElementInterface::getPluginApiLink
YamlFormElementBase::getPluginApiUrl public function Get the URL for the element's API documentation. Overrides YamlFormElementInterface::getPluginApiUrl
YamlFormElementBase::getPluginLabel public function Gets the label of the plugin instance. Overrides YamlFormElementInterface::getPluginLabel
YamlFormElementBase::getTranslatableProperties public function Get translatable properties. Overrides YamlFormElementInterface::getTranslatableProperties 7
YamlFormElementBase::getTypeName public function Gets the type name (aka id) of the plugin instance with the 'yamlform_' prefix. Overrides YamlFormElementInterface::getTypeName
YamlFormElementBase::hasMultipleValues public function Checks if element value has multiple values. Overrides YamlFormElementInterface::hasMultipleValues 3
YamlFormElementBase::hasProperty public function Determine if an element supports a specified property. Overrides YamlFormElementInterface::hasProperty
YamlFormElementBase::hasWrapper public function Checks if the element has a wrapper. Overrides YamlFormElementInterface::hasWrapper
YamlFormElementBase::initialize public function Initialize an element to be displayed, rendered, or exported. Overrides YamlFormElementInterface::initialize 1
YamlFormElementBase::isComposite public function Checks if element is a composite element. Overrides YamlFormElementInterface::isComposite
YamlFormElementBase::isContainer public function Checks if element is a container that can contain elements. Overrides YamlFormElementInterface::isContainer 3
YamlFormElementBase::isDisabled public function Checks if element is disabled. Overrides YamlFormElementInterface::isDisabled
YamlFormElementBase::isEnabled public function Checks if element is enabled. Overrides YamlFormElementInterface::isEnabled 1
YamlFormElementBase::isHidden public function Checks if element is hidden. Overrides YamlFormElementInterface::isHidden
YamlFormElementBase::isInput public function Checks if the element carries a value. Overrides YamlFormElementInterface::isInput 5
YamlFormElementBase::isRoot public function Checks if element is a root element. Overrides YamlFormElementInterface::isRoot 1
YamlFormElementBase::postCreate public function Acts on a form submission element after it is created. Overrides YamlFormElementInterface::postCreate 1
YamlFormElementBase::postDelete public function Delete any additional value associated with an element. Overrides YamlFormElementInterface::postDelete 2
YamlFormElementBase::postLoad public function Acts on loaded form submission. Overrides YamlFormElementInterface::postLoad 1
YamlFormElementBase::postSave public function Acts on a saved form submission element before the insert or update hook is invoked. Overrides YamlFormElementInterface::postSave 2
YamlFormElementBase::preCreate public function Changes the values of an entity before it is created. Overrides YamlFormElementInterface::preCreate 1
YamlFormElementBase::preDelete public function 1
YamlFormElementBase::prefixExportHeader protected function Prefix an element's export header.
YamlFormElementBase::prepareWrapper protected function Set an elements Flexbox and #states wrapper. 1
YamlFormElementBase::preSave public function Acts on a form submission element before the presave hook is invoked. Overrides YamlFormElementInterface::preSave 2
YamlFormElementBase::setConfigurationFormDefaultValue protected function Set an element's configuration form element default value. 2
YamlFormElementBase::setConfigurationFormDefaultValueRecursive protected function Set configuration form default values recursively.
YamlFormElementBase::setDefaultValue public function Set an element's default value using saved data. Overrides YamlFormElementInterface::setDefaultValue 8
YamlFormElementBase::submitConfigurationForm public function Form submission handler. Overrides PluginFormInterface::submitConfigurationForm
YamlFormElementBase::validateConfigurationForm public function Form validation handler. Overrides PluginFormInterface::validateConfigurationForm 3
YamlFormElementBase::validateUnique public static function Form API callback. Validate #unique value.
YamlFormElementBase::__construct public function Constructs a Drupal\Component\Plugin\PluginBase object. Overrides PluginBase::__construct