You are here

public function YamlFormCompositeBase::getDefaultProperties in YAML Form 8

Only a few elements don't inherit these default properties.

Overrides YamlFormElementBase::getDefaultProperties

See also

\Drupal\yamlform\Plugin\YamlFormElement\Textarea

\Drupal\yamlform\Plugin\YamlFormElement\YamlFormLikert

\Drupal\yamlform\Plugin\YamlFormElement\YamlFormCompositeBase

\Drupal\yamlform\Plugin\YamlFormElement\ContainerBase

1 call to YamlFormCompositeBase::getDefaultProperties()
YamlFormCreditCard::getDefaultProperties in src/Plugin/YamlFormElement/YamlFormCreditCard.php
Only a few elements don't inherit these default properties.
2 methods override YamlFormCompositeBase::getDefaultProperties()
YamlFormCreditCard::getDefaultProperties in src/Plugin/YamlFormElement/YamlFormCreditCard.php
Only a few elements don't inherit these default properties.
YamlFormLocation::getDefaultProperties in src/Plugin/YamlFormElement/YamlFormLocation.php
Only a few elements don't inherit these default properties.

File

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

Class

YamlFormCompositeBase
Provides a base for composite elements.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

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;
}