Skip to content

Commit

Permalink
Merge pull request #5957 from filamentphp/feature/rc/form-component-a…
Browse files Browse the repository at this point in the history
…ction-mount-arguments
  • Loading branch information
danharrin committed Mar 17, 2023
1 parent 61548f9 commit eb4c7c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions resources/lang/de/components.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
'buttons' => [

'clone_item' => [
'label' => 'Klonen',
'label' => 'Kopieren',
],

'create_item' => [
'label' => 'Zu :label hinzufügen',
'label' => 'Hinzufügen',
],

'create_item_between' => [
Expand Down Expand Up @@ -128,15 +128,15 @@
'buttons' => [

'create_item' => [
'label' => 'Zu :label hinzufügen',
'label' => 'Hinzufügen',
],

'delete_item' => [
'label' => 'Löschen',
],

'clone_item' => [
'label' => 'Klonen',
'label' => 'Kopieren',
],

'move_item' => [
Expand Down
12 changes: 10 additions & 2 deletions src/Concerns/HasFormComponentActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ trait HasFormComponentActions
{
public $mountedFormComponentAction = null;

public $mountedFormComponentActionArguments = [];

public $mountedFormComponentActionData = [];

public $mountedFormComponentActionComponent = null;
Expand Down Expand Up @@ -56,7 +58,10 @@ public function callMountedFormComponentAction(?string $arguments = null)
return;
}

$action->arguments($arguments ? json_decode($arguments, associative: true) : []);
$action->arguments(array_merge(
$this->mountedFormComponentActionArguments ?? [],
$arguments ? json_decode($arguments, associative: true) : [],
));

$form = $this->getMountedFormComponentActionForm();

Expand Down Expand Up @@ -108,10 +113,11 @@ public function getMountedFormComponentAction(): Action | Closure | null
return $this->getMountedFormComponentActionComponent()?->getAction($this->mountedFormComponentAction);
}

public function mountFormComponentAction(string $component, string $name)
public function mountFormComponentAction(string $component, string $name, array $arguments = [])
{
$this->mountedFormComponentActionComponent = $component;
$this->mountedFormComponentAction = $name;
$this->mountedFormComponentActionArguments = $arguments;

$action = $this->getMountedFormComponentAction();

Expand All @@ -132,6 +138,8 @@ public function mountFormComponentAction(string $component, string $name)
return;
}

$action->arguments($this->mountedFormComponentActionArguments);

$this->cacheForm(
'mountedFormComponentActionForm',
fn () => $this->getMountedFormComponentActionForm(),
Expand Down

0 comments on commit eb4c7c7

Please sign in to comment.