Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow dynamic title on InlineRepeater #2493

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Services/Forms/InlineRepeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
private ?bool $allowBrowse = false,
private ?array $browser = null,
private ?int $max = null,
private ?string $titleField = null,
private ?bool $hideTitlePrefix = false,
) {
}

Expand All @@ -44,6 +46,20 @@
return $this;
}

public function titleField(string $field): static

Check warning on line 49 in src/Services/Forms/InlineRepeater.php

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L49

Added line #L49 was not covered by tests
{
$this->titleField = $field;

Check warning on line 51 in src/Services/Forms/InlineRepeater.php

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L51

Added line #L51 was not covered by tests

return $this;

Check warning on line 53 in src/Services/Forms/InlineRepeater.php

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L53

Added line #L53 was not covered by tests
}

public function hideTitlePrefix(bool $hide = true): static

Check warning on line 56 in src/Services/Forms/InlineRepeater.php

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L56

Added line #L56 was not covered by tests
{
$this->hideTitlePrefix = $hide;

Check warning on line 58 in src/Services/Forms/InlineRepeater.php

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L58

Added line #L58 was not covered by tests

return $this;

Check warning on line 60 in src/Services/Forms/InlineRepeater.php

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L60

Added line #L60 was not covered by tests
}

public static function make(): self
{
$self = new self();
Expand Down Expand Up @@ -160,6 +176,8 @@
$repeaterBlock->trigger = $this->trigger ?? 'Add ' . $this->label;
$repeaterBlock->selectTrigger = $this->selectTrigger ?? 'Select ' . $this->label;
$repeaterBlock->group = 'dynamic';
$repeaterBlock->titleField = $this->titleField;
$repeaterBlock->hideTitlePrefix = $this->hideTitlePrefix;

Check warning on line 180 in src/Services/Forms/InlineRepeater.php

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L179-L180

Added lines #L179 - L180 were not covered by tests

return $repeaterBlock;
}
Expand Down
Loading