Skip to content

Commit

Permalink
A few more CC things
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeder committed Dec 2, 2024
1 parent f01cc3a commit 37a6637
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
14 changes: 1 addition & 13 deletions modules/json_form_widget/src/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down Expand Up @@ -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.
*
Expand Down
5 changes: 4 additions & 1 deletion modules/json_form_widget/src/WidgetRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ public function handleListElement(mixed $spec, array $element) {
* The dropdown element configured.
*/
public function getDropdownElement(mixed $element, mixed $spec, mixed $titleProperty = FALSE) {
ArrayHelper::flattenArrayElementFieldset($element);
// Flatten array element if it is a fieldset.
if (isset($element['field']) && $element['#type'] == 'fieldset') {
$element = ['#required' => ($element['#required'] ?? FALSE)] + $element['field'];
}
$element['#type'] = $this->getSelectType($spec);
$element['#options'] = $this->getDropdownOptions($spec->source, $titleProperty);
if ($element['#type'] === 'select_or_other_select') {
Expand Down

0 comments on commit 37a6637

Please sign in to comment.