Skip to content

Commit

Permalink
DataAttribute for InlineAdd and InlineEdit #1107
Browse files Browse the repository at this point in the history
  • Loading branch information
rendix2 authored and f3l1x committed May 3, 2024
1 parent 100c281 commit 86c88ed
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/InlineEdit/InlineEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class InlineEdit
*/
protected bool $showNonEditingColumns = true;

/** @var array */

Check failure on line 61 in src/InlineEdit/InlineEdit.php

View workflow job for this annotation

GitHub Actions / Codesniffer / Codesniffer (8.3)

Property \Contributte\Datagrid\InlineEdit\InlineEdit::$dataAttributes has useless @var annotation.
protected array $dataAttributes = [];

public function __construct(protected Datagrid $grid, protected ?string $primaryWhereColumn = null)
{
$this->title = 'contributte_datagrid.edit';
Expand Down Expand Up @@ -94,6 +97,12 @@ public function renderButton(Row $row): Html

$this->tryAddIcon($a, $this->getIcon(), $this->getText());

if ($this->dataAttributes !== []) {
foreach ($this->dataAttributes as $key => $value) {
$a->data((string) $key, $value);
}
}

$a->addText($this->text);

if ($this->title !== null) {
Expand Down Expand Up @@ -122,6 +131,12 @@ public function renderButtonAdd(): Html

$this->tryAddIcon($a, $this->getIcon(), $this->getText());

if ($this->dataAttributes !== []) {
foreach ($this->dataAttributes as $key => $value) {
$a->data((string) $key, $value);
}
}

$a->addText($this->text);

if ($this->title !== null) {
Expand Down Expand Up @@ -199,4 +214,14 @@ public function showNonEditingColumns(): bool
return $this->showNonEditingColumns;
}

/**
* @return static
*/
public function setDataAttribute(string $key, mixed $value): self
{
$this->dataAttributes[$key] = $value;

return $this;
}

}

0 comments on commit 86c88ed

Please sign in to comment.