-
Notifications
You must be signed in to change notification settings - Fork 111
Ui\Dropdown with typecasting bug #2236
Copy link
Copy link
Closed
Labels
Description
Steps to reproduce:
- Add a Ui\Dropdown view and setModel for any model with a usual bigint idField
- Configure Dropdown->onChange to handle selected item
- Select an entry of the dropdown
Sample code:
$agentdropdown = \Atk4\Ui\Dropdown::addTo($app, ['Select agent', 'dropdownOptions' => ['on' => 'hover']]);
$agentdropdown->setModel($agentmodel);
$agentdropdown->onChange(static function ($itemId) {
return "do something with ".$itemId;
});
Typecasting error TypeError: Atk4\Ui\Dropdown::Atk4\Ui\{closure}(): Argument #2 ($value) must be of type string, int given, called in vendor/atk4/ui/src/JsCallback.php on line 90
Solution:
Line 57 in 7383f1e
| $this->cb->set(static function (Jquery $j, string $value) use ($fx) { |
The itemId here is forced to be string, however the idField is typecasted as int. This has to be adapted.
Reactions are currently unavailable