Skip to content

Commit

Permalink
fix infer for cascadefrom
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Feb 12, 2024
1 parent 7cef7c3 commit 7ab439e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Form/AbstractLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,20 @@ public function addControl(string $name, $control = [], array $fieldSeed = []):
if (is_a($controlClass, Control\Checkbox::class, true)) {
$fieldSeed['type'] = 'boolean';
} elseif (is_a($controlClass, Control\Dropdown::class, true) || is_a($controlClass, Control\Lookup::class, true)) {
$dropdownModel = $control instanceof Control ? $control->model : ($control['model'] ?? null);
if ($dropdownModel !== null) {
$fieldSeed['type'] = $dropdownModel->getField($dropdownModel->idField)->type;
if (is_a($controlClass, Control\DropdownCascade::class, true)) {
$cascadeFromControl = $control instanceof Control ? $control->cascadeFrom : ($control['cascadeFrom'] ?? null);

Check failure on line 53 in src/Form/AbstractLayout.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Access to an undefined property Atk4\Ui\Form\Control::$cascadeFrom.

Check failure on line 53 in src/Form/AbstractLayout.php

View workflow job for this annotation

GitHub Actions / Smoke (latest, StaticAnalysis)

Access to an undefined property Atk4\Ui\Form\Control::$cascadeFrom.
if ($cascadeFromControl !== null) {
if (!$cascadeFromControl instanceof Control) {
$cascadeFromControl = $this->form->getControl($cascadeFromControl);
}

$fieldSeed['type'] = $cascadeFromControl->entityField->getField()->type;
}
} else {
$dropdownModel = $control instanceof Control ? $control->model : ($control['model'] ?? null);
if ($dropdownModel !== null) {
$fieldSeed['type'] = $dropdownModel->getField($dropdownModel->idField)->type;
}
}
} elseif (is_a($controlClass, Control\Calendar::class, true)) {
$calendarType = $control instanceof Control\Calendar ? $control->type : ($control['type'] ?? null);
Expand Down

0 comments on commit 7ab439e

Please sign in to comment.