Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions docs/guide/form-fields/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
38 changes: 34 additions & 4 deletions docs/guide/upgrading/9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,13 +533,43 @@ 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)

The `->withSingleField()` method was deprecated, in favor of:

- `->withField(string $fieldKey)` for simple fields
- `->withListField(string $fieldKey, Closure $subLayoutCallback)` for List fields, which requires a sub-layout handled by a callback.
The `->withSingleField()` method was deprecated, in favor of `->withField(string $fieldKey)` for simple fields.

The method `->withFields(string ...$fieldKeys)`, used for multiple fields layout, remains unchanged.

## Form and Show list fields must now use `->withListField()` instead of `->withSingleField()` in layout

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

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.
Expand Down
Loading