public static function PaymentReferenceBase::processMaxWeight in Payment 8.2
Implements form #process callback.
File
- src/
Element/ PaymentReferenceBase.php, line 299
Class
- PaymentReferenceBase
- Provides a base for payment reference elements.
Namespace
Drupal\payment\ElementCode
public static function processMaxWeight(array &$element, FormStateInterface $form_state, array $form) {
$parent_element = NestedArray::getValue($form, array_slice($element['#array_parents'], 0, -1));
$weights = [];
foreach (Element::children($parent_element) as $sibling_key) {
$weights[] = isset($parent_element[$sibling_key]['#weight']) ? $parent_element[$sibling_key]['#weight'] : 0;
}
$element['#weight'] = max($weights) + 1;
return $element;
}