Skip to content

Commit

Permalink
Added a possibility to change 'Add row' label for matrix field
Browse files Browse the repository at this point in the history
  • Loading branch information
Ercogx committed Apr 17, 2024
1 parent 7e6b568 commit cb4628b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion resources/views/fields/matrix.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<a href="#" data-action="matrix#addRow" class="btn btn-block small text-muted">
<x-orchid-icon path="bs.plus-circle" class="me-2"/>

<span>{{ __('Add row') }}</span>
<span>{{ $addRowLabel ?? __('Add row') }}</span>
</a>
</th>
</tr>
Expand Down
11 changes: 11 additions & 0 deletions src/Screen/Fields/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Matrix extends Field
'maxRows' => 0,
'keyValue' => false,
'fields' => [],
'addRowLabel' => null,
'columns' => [
'key',
'value',
Expand Down Expand Up @@ -107,6 +108,16 @@ public function fields(array $fields = []): self
return $this->set('fields', $fields);
}

/**
* @param string $label
*
* @return self
*/
public function addRowLabel(string $label): self
{
return $this->set('addRowLabel', $label);
}

protected function getIdPrefix(): string
{
$idPrefix = $this->get('idPrefix');
Expand Down

0 comments on commit cb4628b

Please sign in to comment.