Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion demos/form/form2.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Atk4\Ui\Header;
use Atk4\Ui\Js\Jquery;
use Atk4\Ui\Js\JsBlock;
use Atk4\Ui\Js\JsCallbackLoadableValue;
use Atk4\Ui\Js\JsToast;
use Atk4\Ui\Label;

Expand Down Expand Up @@ -39,7 +40,7 @@
}

return new JsToast('This country name can be added.');
}, ['args' => [$nameInput->jsInput()->val()]]);
}, ['args' => [new JsCallbackLoadableValue($nameInput->jsInput()->val(), static fn ($v) => $v)]]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for myself - can this be detected using phpstan or no lately on runtime?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for me, but looks like black magic, not low code :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low code, but still we require explicit code to enforce strong typecasting. Here we indicate we want to keep string type.

With improve method param type PHPStan should be able to detect the issue.

Also we should throw if the type is not JsCallbackLoadableValue in JsCallback. The reason you got "argument error" is passed JsExpression implements __call. I will work on this.


// form codes field group
$formCodes = $form->addGroup(['Codes']);
Expand Down