From b35db2fac6ef942bf2d5da926de1d69a64af2f1f Mon Sep 17 00:00:00 2001 From: PatrickePatate Date: Mon, 6 Jan 2025 11:07:11 +0100 Subject: [PATCH 1/3] Fix doc --- docs/guide/form-fields/list.md | 5 +++-- docs/guide/upgrading/9.0.md | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/guide/form-fields/list.md b/docs/guide/form-fields/list.md index b22c4d44c..85abb3cd3 100644 --- a/docs/guide/form-fields/list.md +++ b/docs/guide/form-fields/list.md @@ -99,8 +99,9 @@ class MyForm extends SharpForm function buildFormLayout(FormLayout $formLayout) { $this->addColumn(6, function (FormLayoutColumn $column) { - $column->withSingleField('pieces', function (FormLayoutColumn $listItem) { - $listItem->withField('acquisition_date') + $column->withListField('pieces', function (FormLayoutColumn $listItem) { + $listItem + ->withField('acquisition_date') ->withField('title') ->withField('artist_id'); }); diff --git a/docs/guide/upgrading/9.0.md b/docs/guide/upgrading/9.0.md index d5e0b3ebf..3fab1e65d 100644 --- a/docs/guide/upgrading/9.0.md +++ b/docs/guide/upgrading/9.0.md @@ -533,6 +533,11 @@ This is not a breaking change, in fact you can ignore this step entirely, but si ## Form and Show layout methods were renamed (old ones are deprecated) +::: warning +List Fields that used `->withSingleField()` will not work anymore as these methods no longer take a callback. +You must migrate your list fields to the new layout method `->withListField()`. +::: + The `->withSingleField()` method was deprecated, in favor of: - `->withField(string $fieldKey)` for simple fields From 5aabd7df3c925c1b00d67f181030cb9deaf24efb Mon Sep 17 00:00:00 2001 From: antoine Date: Mon, 6 Jan 2025 14:12:36 +0100 Subject: [PATCH 2/3] update migration --- docs/guide/upgrading/9.0.md | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/docs/guide/upgrading/9.0.md b/docs/guide/upgrading/9.0.md index 3fab1e65d..186d145f2 100644 --- a/docs/guide/upgrading/9.0.md +++ b/docs/guide/upgrading/9.0.md @@ -533,17 +533,49 @@ This is not a breaking change, in fact you can ignore this step entirely, but si ## Form and Show layout methods were renamed (old ones are deprecated) -::: warning -List Fields that used `->withSingleField()` will not work anymore as these methods no longer take a callback. -You must migrate your list fields to the new layout method `->withListField()`. -::: +The `->withSingleField()` method was deprecated, in favor of `->withField(string $fieldKey)` for simple fields. -The `->withSingleField()` method was deprecated, in favor of: +The method `->withFields(string ...$fieldKeys)`, used for multiple fields layout, remains unchanged. -- `->withField(string $fieldKey)` for simple fields -- `->withListField(string $fieldKey, Closure $subLayoutCallback)` for List fields, which requires a sub-layout handled by a callback. +## Form and Show list fields must now use `->withListField()` instead of `->withSingleField()` in layout -The method `->withFields(string ...$fieldKeys)`, used for multiple fields layout, remains unchanged. +In 8.x: +```php +class MyForm extends SharpForm +{ + function buildFormLayout(FormLayout $formLayout) + { + $this->addColumn(6, function (FormLayoutColumn $column) { + $column->withSingleField(string $fieldKey, function (FormLayoutColumn $listItem) { + $listItem->withField('title'); + }); + }); + } +} +``` + +In 9.x: +```php +class MyForm extends SharpForm +{ + function buildFormLayout(FormLayout $formLayout) + { + $this->addColumn(6, function (FormLayoutColumn $column) { + // now `->withListField()` + $column->withListField(string $fieldKey, function (FormLayoutColumn $listItem) { + $listItem->withField('title'); + }); + }); + } +} +``` + + ## Form and Show Fields are now formatted even if you don’t transform them From f5b6508b30bb7d345f29cf4a9298ecec2b9f21a2 Mon Sep 17 00:00:00 2001 From: antoine Date: Mon, 6 Jan 2025 14:13:06 +0100 Subject: [PATCH 3/3] cleanup --- docs/guide/upgrading/9.0.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/guide/upgrading/9.0.md b/docs/guide/upgrading/9.0.md index 186d145f2..0216ff54e 100644 --- a/docs/guide/upgrading/9.0.md +++ b/docs/guide/upgrading/9.0.md @@ -570,13 +570,6 @@ class MyForm extends SharpForm } ``` - - ## Form and Show Fields are now formatted even if you don’t transform them This shouldn’t cause any trouble, as this is a fix, but it could break unorthodox code: field formatters (which are used to format the field value for the frontend) are now properly and always called before displaying data to the front, even if you don’t transform your data with `$this->transform()` method.