Skip to content

Commit

Permalink
feat: Async selectors for form
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Jan 12, 2025
1 parent 5744f5a commit bda5502
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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 bda5502

Please sign in to comment.