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

fix: allow buttonAsLink option on inline repeaters #2522

Merged
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions src/Services/Forms/InlineRepeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
private ?int $max = null,
private ?string $titleField = null,
private ?bool $hideTitlePrefix = false,
private ?bool $buttonAsLink = false
) {
}

Expand Down Expand Up @@ -149,6 +150,13 @@
return $this;
}

public function buttonAsLink(bool $buttonAsLink): static

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

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L153

Added line #L153 was not covered by tests
danieldevine marked this conversation as resolved.
Show resolved Hide resolved
{
$this->buttonAsLink = $buttonAsLink;

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

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L155

Added line #L155 was not covered by tests

return $this;

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

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L157

Added line #L157 was not covered by tests
}

public function renderForm(): View
{
return view('twill::partials.form.renderer.block_form', [
Expand Down Expand Up @@ -203,6 +211,10 @@
$repeater->max($this->max);
}

if ($this->buttonAsLink) {
$repeater->buttonAsLink($this->buttonAsLink);

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

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L214-L215

Added lines #L214 - L215 were not covered by tests
}

$repeater->renderForBlocks = $this->renderForBlocks ?? false;
return $repeater->render();
}
Expand Down
Loading