mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
add table select arguments
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
'record' => $getRecord(),
|
||||
'relationshipName' => $getRelationshipName(),
|
||||
'tableConfiguration' => base64_encode($getTableConfiguration()),
|
||||
'tableSelectArguments' => $getTableSelectArguments(),
|
||||
'wire:model' => $getStatePath(),
|
||||
], key($getLivewireKey()))
|
||||
</div>
|
||||
|
||||
@@ -56,6 +56,11 @@ class ModalTableSelect extends Field
|
||||
|
||||
protected ?Closure $modifySelectActionUsing = null;
|
||||
|
||||
/**
|
||||
* @var array<mixed> | Closure
|
||||
*/
|
||||
protected array | Closure $tableSelectArguments = [];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -93,6 +98,16 @@ class ModalTableSelect extends Field
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed> | Closure $arguments
|
||||
*/
|
||||
public function tableSelectArguments(array | Closure $arguments): static
|
||||
{
|
||||
$this->tableSelectArguments = $arguments;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSelectAction(): Action
|
||||
{
|
||||
$action = Action::make('select')
|
||||
@@ -129,7 +144,8 @@ class ModalTableSelect extends Field
|
||||
->tableConfiguration($this->getTableConfiguration())
|
||||
->relationshipName($this->getRelationshipName())
|
||||
->multiple()
|
||||
->maxItems($this->getMaxItems());
|
||||
->maxItems($this->getMaxItems())
|
||||
->tableSelectArguments($this->getTableSelectArguments());
|
||||
|
||||
if ($this->modifyTableSelectUsing) {
|
||||
$select = $this->evaluate(
|
||||
@@ -650,4 +666,12 @@ class ModalTableSelect extends Field
|
||||
{
|
||||
return $this->evaluate($this->tableConfiguration) ?? throw new Exception('The [tableConfiguration()] method must be set when using a [TableSelect] component.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public function getTableSelectArguments(): array
|
||||
{
|
||||
return $this->evaluate($this->tableSelectArguments) ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ class TableSelect extends Field
|
||||
|
||||
protected bool | Closure $isMultiple = false;
|
||||
|
||||
/**
|
||||
* @var array<mixed> | Closure
|
||||
*/
|
||||
protected array | Closure $tableSelectArguments = [];
|
||||
|
||||
public function tableConfiguration(string | Closure $tableConfiguration): static
|
||||
{
|
||||
$this->tableConfiguration = $tableConfiguration;
|
||||
@@ -39,11 +44,29 @@ class TableSelect extends Field
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed> | Closure $arguments
|
||||
*/
|
||||
public function tableSelectArguments(array | Closure $arguments): static
|
||||
{
|
||||
$this->tableSelectArguments = $arguments;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTableConfiguration(): string
|
||||
{
|
||||
return $this->evaluate($this->tableConfiguration) ?? throw new Exception('The [tableConfiguration()] method must be set when using a [TableSelect] component.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public function getTableSelectArguments(): array
|
||||
{
|
||||
return $this->evaluate($this->tableSelectArguments) ?? [];
|
||||
}
|
||||
|
||||
public function relationship(string | Closure | null $name): static
|
||||
{
|
||||
$this->relationshipName($name);
|
||||
|
||||
@@ -45,6 +45,12 @@ class TableSelectLivewireComponent extends Component implements HasActions, HasF
|
||||
#[Locked]
|
||||
public string $tableConfiguration;
|
||||
|
||||
/**
|
||||
* @var array<mixed>
|
||||
*/
|
||||
#[Locked]
|
||||
public array $tableSelectArguments = [];
|
||||
|
||||
/**
|
||||
* @var string | array<string> | null
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user