public static function WebformElementHelper::getIgnoredProperties in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Utility/WebformElementHelper.php \Drupal\webform\Utility\WebformElementHelper::getIgnoredProperties()
Get ignored properties from a webform element.
Parameters
array $element: A webform element.
Return value
array An array of ignored properties.
3 calls to WebformElementHelper::getIgnoredProperties()
- WebformElementBase::validateConfigurationForm in src/
Plugin/ WebformElementBase.php - Form validation handler.
- WebformElementHelperTest::testGetIgnoredProperties in tests/
src/ Unit/ Utility/ WebformElementHelperTest.php - Tests WebformElementHelper::GetIgnoredProperties().
- WebformEntityElementsValidator::validateProperties in src/
WebformEntityElementsValidator.php - Validate that elements are not using ignored properties.
File
- src/
Utility/ WebformElementHelper.php, line 402
Class
- WebformElementHelper
- Helper class webform element methods.
Namespace
Drupal\webform\UtilityCode
public static function getIgnoredProperties(array $element) {
$ignored_properties = [];
foreach ($element as $key => $value) {
if (static::property($key)) {
if (self::isIgnoredProperty($key)) {
// Computed elements use #ajax as boolean and should not be ignored.
// @see \Drupal\webform\Element\WebformComputedBase
$is_ajax_computed = $key === '#ajax' && is_bool($value);
if (!$is_ajax_computed) {
$ignored_properties[$key] = $key;
}
}
elseif ($key === '#element' && is_array($value) && isset($element['#type']) && $element['#type'] === 'webform_composite') {
foreach ($value as $composite_value) {
// Multiple sub composite elements are not supported.
if (isset($composite_value['#multiple'])) {
$ignored_properties['#multiple'] = t('Custom composite sub elements do not support elements with multiple values.');
}
// Check that sub composite element type is supported.
if (isset($composite_value['#type']) && !WebformCompositeBase::isSupportedElementType($composite_value['#type'])) {
$composite_type = $composite_value['#type'];
$ignored_properties["composite.{$composite_type}"] = t('Custom composite elements do not support the %type element.', [
'%type' => $composite_type,
]);
}
$ignored_properties += self::getIgnoredProperties($composite_value);
}
}
}
elseif (is_array($value)) {
$ignored_properties += self::getIgnoredProperties($value);
}
}
return $ignored_properties;
}