$value) { $this->setProperty($key, $value); } } parent::setOptions($options, $resetValidators); } /** * Returns a unique identifier of this element. * While element identifiers are only unique within one form, * this includes the identifier of the form itself, making it "globally" unique * * @return string the "globally" unique identifier of this element */ public function getUniqueIdentifier(): string { $formDefinition = $this->getRootForm(); return sprintf('%s-%s', $formDefinition->getIdentifier(), $this->identifier); } /** * Get the default value with which the Form Element should be initialized * during display. * Note: This is currently not used for section elements * * @return mixed the default value for this Form Element */ public function getDefaultValue() { return null; } /** * Set the default value with which the Form Element should be initialized * during display. * Note: This is currently ignored for section elements * * @param mixed $defaultValue the default value for this Form Element */ public function setDefaultValue($defaultValue) {} /** * Get all element-specific configuration properties */ public function getProperties(): array { return $this->properties; } /** * Set an element-specific configuration property. * * @param mixed $value */ public function setProperty(string $key, $value) { if (is_array($value) && isset($this->properties[$key]) && is_array($this->properties[$key])) { ArrayUtility::mergeRecursiveWithOverrule($this->properties[$key], $value); $this->properties[$key] = ArrayUtility::removeNullValuesRecursive($this->properties[$key]); } elseif ($value === null) { unset($this->properties[$key]); } else { $this->properties[$key] = $value; } } /** * Whether or not this element is required */ public function isRequired(): bool { foreach ($this->getValidators() as $validator) { if ($validator instanceof NotEmptyValidator) { return true; } } return false; } }