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 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
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,
protected ?array $connectedTo = null,
) {
}
Expand Down Expand Up @@ -150,6 +151,13 @@
return $this;
}

public function buttonAsLink(bool $buttonAsLink = true): static

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

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L154

Added line #L154 was not covered by tests
{
$this->buttonAsLink = $buttonAsLink;

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

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L156

Added line #L156 was not covered by tests

return $this;

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

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L158

Added line #L158 was not covered by tests
}

public function renderForm(): View
{
return view('twill::partials.form.renderer.block_form', [
Expand Down Expand Up @@ -207,6 +215,10 @@
$repeater->connectedTo($this->connectedTo['fieldName'], $this->connectedTo['fieldValues'], $this->connectedTo);
}

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

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

View check run for this annotation

Codecov / codecov/patch

src/Services/Forms/InlineRepeater.php#L218-L219

Added lines #L218 - L219 were not covered by tests
}

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