Skip to content

Commit

Permalink
Merge pull request #1466 from moonshine-software/form-async-selectors
Browse files Browse the repository at this point in the history
feat: Async selectors for form
  • Loading branch information
lee-to authored Jan 12, 2025
2 parents 5744f5a + a81c40f commit 85e6e55
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/UI/dist/assets/app.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/UI/resources/js/Components/FormBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export default (name = '', initData = {}, reactive = {}) => ({
callback = initCallback(callback)

componentRequestData
.withSelector(form.dataset.asyncSelector ?? '')
.withBeforeRequest(callback.beforeRequest)
.withResponseHandler(callback.responseHandler)
.withEvents(events)
Expand Down
7 changes: 7 additions & 0 deletions src/UI/src/Components/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ public function asyncMethod(
);
}

public function asyncSelector(string|array $selector): self
{
return $this->customAttributes([
'data-async-selector' => \is_array($selector) ? implode(',', $selector) : $selector,
]);
}

public function reactiveUrl(Closure|string $reactiveUrl): self
{
$this->reactiveUrl = $reactiveUrl;
Expand Down

0 comments on commit 85e6e55

Please sign in to comment.