protected function Webform::initElements in Webform 8.5
Same name and namespace in other branches
- 6.x src/Entity/Webform.php \Drupal\webform\Entity\Webform::initElements()
Initialize and parse webform elements.
22 calls to Webform::initElements()
- Webform::getAssets in src/
Entity/ Webform.php - Returns the webform's global and custom CSS and JavaScript assets.
- Webform::getElementsAttachments in src/
Entity/ Webform.php - Get webform attachment elements.
- Webform::getElementsComputed in src/
Entity/ Webform.php - Get webform computed elements.
- Webform::getElementsDecoded in src/
Entity/ Webform.php - Get webform elements decoded as an associative array.
- Webform::getElementsDecodedAndFlattened in src/
Entity/ Webform.php - Get webform raw elements decoded and flattened into an associative array.
File
- src/
Entity/ Webform.php, line 1449
Class
- Webform
- Defines the webform entity.
Namespace
Drupal\webform\EntityCode
protected function initElements() {
if (isset($this->elementsInitialized)) {
return;
}
// Reset everything excepts pages.
// @todo Figure out how we can call ::resetElements.
// @see \Drupal\webform\Entity\Webform::resetElements
$this->hasFlexboxLayout = FALSE;
$this->hasContainer = FALSE;
$this->hasConditions = FALSE;
$this->hasRequired = FALSE;
$this->elementsPrepopulate = [];
$this->elementsActions = [];
$this->elementsWizardPages = [];
$this->elementsDecodedAndFlattened = [];
$this->elementsInitializedAndFlattened = [];
$this->elementsInitializedFlattenedAndHasValue = [];
$this->elementsTranslations = [];
$this->elementsManagedFiles = [];
$this->elementsAttachments = [];
$this->elementsComputed = [];
$this->elementsVariant = [];
$this->elementsCss = [];
$this->elementsJavaScript = [];
$this->elementsDefaultData = [];
try {
// Init element translations.
$this
->initElementsTranslation();
// Since YAML supports simple values.
$elements = WebformYaml::decode($this->elements);
$elements = is_array($elements) ? $elements : [];
$this->elementsDecoded = $elements;
} catch (\Exception $exception) {
$link = $this
->toLink($this
->t('Edit'), 'edit-form')
->toString();
\Drupal::logger('webform')
->notice('%title elements are not valid. @message', [
'%title' => $this
->label(),
'@message' => $exception
->getMessage(),
'link' => $link,
]);
$elements = FALSE;
}
if ($elements !== FALSE) {
$elements = WebformElementHelper::removeIgnoredProperties($elements);
$this
->initElementsRecursive($elements);
$this
->invokeHandlers('alterElements', $elements, $this);
}
$this->elementsInitialized = $elements;
}