You are here

public function YamlFormElementBase::getFormat in YAML Form 8

Get element's format name by looking for '#format' property, global settings, and finally default settings.

Parameters

array $element: An element.

Return value

string An element's format name.

Overrides YamlFormElementInterface::getFormat

25 calls to YamlFormElementBase::getFormat()
BooleanBase::formatText in src/Plugin/YamlFormElement/BooleanBase.php
Format an element's value as plain text.
Color::formatHtml in src/Plugin/YamlFormElement/Color.php
Format an element's value as HTML.
DateBase::getFormat in src/Plugin/YamlFormElement/DateBase.php
Get element's format name by looking for '#format' property, global settings, and finally default settings.
Email::formatHtml in src/Plugin/YamlFormElement/Email.php
Format an element's value as HTML.
LanguageSelect::formatText in src/Plugin/YamlFormElement/LanguageSelect.php
Format an element's value as plain text.

... See full list

1 method overrides YamlFormElementBase::getFormat()
DateBase::getFormat in src/Plugin/YamlFormElement/DateBase.php
Get element's format name by looking for '#format' property, global settings, and finally default settings.

File

src/YamlFormElementBase.php, line 678

Class

YamlFormElementBase
Provides a base class for a form element.

Namespace

Drupal\yamlform

Code

public function getFormat(array $element) {
  if (isset($element['#format'])) {
    return $element['#format'];
  }
  elseif ($default_format = $this->configFactory
    ->get('yamlform.settings')
    ->get('format.' . $this
    ->getPluginId())) {
    return $default_format;
  }
  else {
    return $this
      ->getDefaultFormat();
  }
}