$element['#attributes'
] +=
['dir' => LanguageInterface::DIRECTION_LTR
];
// The source element defaults to array('name'), but may have been overridden.
if (empty($element['#machine_name'
]['source'
])) { return $element;
} // Retrieve the form element containing the human-readable name from the
// complete form in $form_state. By reference, because we may need to append
// a #field_suffix that will hold the live preview.
$key_exists = NULL;
$source = NestedArray::
getValue($form_state->
getCompleteForm(),
$element['#machine_name'
]['source'
],
$key_exists);
if (!
$key_exists) { return $element;
} // The source element must be defined before the machine name element.
if (!
isset($source['#id'
])) { $element_parents =
implode('][',
$element['#array_parents'
]);
$source_parents =
implode('][',
$element['#machine_name'
]['source'
]);
throw new \
LogicException(sprintf('The machine name element "%s" is defined before the source element "%s", it must be defined after or the source element must specify an id.',
$element_parents,
$source_parents));
}