From b9ce716cd5fbe3e6d6589120feb10286a11f3814 Mon Sep 17 00:00:00 2001 From: PatrickePatate Date: Fri, 24 Jan 2025 15:49:03 +0100 Subject: [PATCH 1/2] Fix withFieldset() autocompletion in IDE --- src/Form/Layout/FormLayoutColumn.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Form/Layout/FormLayoutColumn.php b/src/Form/Layout/FormLayoutColumn.php index 254480088..9f5ff8edc 100644 --- a/src/Form/Layout/FormLayoutColumn.php +++ b/src/Form/Layout/FormLayoutColumn.php @@ -6,6 +6,8 @@ class FormLayoutColumn extends LayoutColumn implements HasLayout { + use HasFieldRows; + /** * @param (\Closure(FormLayoutFieldset): mixed)|null $callback * @return $this From 135497a6a21350517a7bce80304b192418a4f918 Mon Sep 17 00:00:00 2001 From: PatrickePatate Date: Fri, 24 Jan 2025 15:59:14 +0100 Subject: [PATCH 2/2] Fix my fix for withFieldset() --- src/Form/Layout/FormLayoutColumn.php | 3 +-- src/Form/Layout/HasFieldRows.php | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Form/Layout/FormLayoutColumn.php b/src/Form/Layout/FormLayoutColumn.php index 9f5ff8edc..62957d55c 100644 --- a/src/Form/Layout/FormLayoutColumn.php +++ b/src/Form/Layout/FormLayoutColumn.php @@ -6,13 +6,12 @@ class FormLayoutColumn extends LayoutColumn implements HasLayout { - use HasFieldRows; /** * @param (\Closure(FormLayoutFieldset): mixed)|null $callback * @return $this */ - public function withFieldset(string $name, ?\Closure $callback = null): self + public function withFieldset(string $name, ?\Closure $callback = null): static { $fieldset = new FormLayoutFieldset($name); diff --git a/src/Form/Layout/HasFieldRows.php b/src/Form/Layout/HasFieldRows.php index 69528f285..fbe72da05 100644 --- a/src/Form/Layout/HasFieldRows.php +++ b/src/Form/Layout/HasFieldRows.php @@ -15,7 +15,7 @@ trait HasFieldRows protected array $rows = []; /** @deprecated use withField() or withListField() instead */ - public function withSingleField(string $fieldKey, ?\Closure $subLayoutCallback = null): self + public function withSingleField(string $fieldKey, ?\Closure $subLayoutCallback = null): static { if ($subLayoutCallback) { return $this->withListField($fieldKey, $subLayoutCallback); @@ -24,7 +24,7 @@ public function withSingleField(string $fieldKey, ?\Closure $subLayoutCallback = return $this->withField($fieldKey); } - public function withField(string $fieldKey): self + public function withField(string $fieldKey): static { $this->addRowLayout([ $this->newLayoutField($this->normalizedFieldsRow([$fieldKey])->first()), @@ -37,7 +37,7 @@ public function withField(string $fieldKey): self * @param (\Closure(LayoutColumn): mixed) $subLayoutCallback * @return $this */ - public function withListField(string $fieldKey, Closure $subLayoutCallback): self + public function withListField(string $fieldKey, Closure $subLayoutCallback): static { $this->addRowLayout([ $this->newLayoutField($fieldKey, $subLayoutCallback), @@ -46,7 +46,7 @@ public function withListField(string $fieldKey, Closure $subLayoutCallback): sel return $this; } - public function withFields(string|int ...$fieldKeys): self + public function withFields(string|int ...$fieldKeys): static { $this ->addRowLayout( @@ -62,7 +62,7 @@ public function withFields(string|int ...$fieldKeys): self * @param (\Closure(LayoutColumn): mixed)|null $subLayoutCallback * @return $this */ - public function insertSingleFieldAt(int $index, string $fieldKey, ?\Closure $subLayoutCallback = null): self + public function insertSingleFieldAt(int $index, string $fieldKey, ?\Closure $subLayoutCallback = null): static { $rows = collect($this->rows); $rows->splice($index, 0, [[$this->newLayoutField($fieldKey, $subLayoutCallback)]]); @@ -71,7 +71,7 @@ public function insertSingleFieldAt(int $index, string $fieldKey, ?\Closure $sub return $this; } - public function insertFieldsAt(int $index, string ...$fieldKeys): self + public function insertFieldsAt(int $index, string ...$fieldKeys): static { $rows = collect($this->rows); $rows->splice($index, 0, [