diff --git a/modules/json_form_widget/src/ArrayHelper.php b/modules/json_form_widget/src/ArrayHelper.php index 799b4b1513..e44ce458e5 100644 --- a/modules/json_form_widget/src/ArrayHelper.php +++ b/modules/json_form_widget/src/ArrayHelper.php @@ -129,7 +129,7 @@ public function handleArrayElement(array $definition, ?array $data, FormStateInt * @return array * Render array for the array parent element. */ - protected function buildArrayParentElement($definition, $is_required, $context_name) { + protected function buildArrayParentElement(array $definition, bool $is_required, string $context_name) { $element = [ '#type' => 'fieldset', '#title' => ($definition['schema']->title ?? $definition['name']), @@ -204,18 +204,6 @@ protected function buildSimpleArrayElement(array $definition, $data, array $cont ]; } - /** - * Flatten array element fieldset w/buttons for processing. - * - * @param array $element - * A form element. - */ - public static function flattenArrayElementFieldset(array &$element): void { - if (isset($element['field']) && $element['#type'] == 'fieldset') { - $element = ['#required' => ($element['#required'] ?? FALSE)] + $element['field']; - } - } - /** * Returns single complex element from array. * diff --git a/modules/json_form_widget/src/WidgetRouter.php b/modules/json_form_widget/src/WidgetRouter.php index 00a0663558..72c0183f03 100644 --- a/modules/json_form_widget/src/WidgetRouter.php +++ b/modules/json_form_widget/src/WidgetRouter.php @@ -147,7 +147,7 @@ public function handleListElement(mixed $spec, array $element) { * The dropdown element configured. */ public function getDropdownElement(mixed $element, mixed $spec, mixed $titleProperty = FALSE) { - ArrayHelper::flattenArrayElementFieldset($element); + static::flattenArrayFieldset($element); $element['#type'] = $this->getSelectType($spec); $element['#options'] = $this->getDropdownOptions($spec->source, $titleProperty); if ($element['#type'] === 'select_or_other_select') { @@ -166,6 +166,18 @@ public function getDropdownElement(mixed $element, mixed $spec, mixed $titleProp return $element; } + /** + * Flatten array element fieldset w/buttons for processing. + * + * @param array $element + * A form element. + */ + public static function flattenArrayFieldset(array &$element): void { + if (isset($element['field']) && $element['#type'] == 'fieldset') { + $element = ['#required' => ($element['#required'] ?? FALSE)] + $element['field']; + } + } + /** * Helper function to get type of pick list. *