Skip to content
Open
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
1 change: 1 addition & 0 deletions en/08_Changelogs/6.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,7 @@ As part of the [improved separation between the view and model layers](#view-lay
- Native indexed PHP arrays can now be passed into templates and iterated over with `<% loop $MyArray %>`.
- Under the hood they are wrapped in [`ArrayList`](api:SilverStripe\Model\List\ArrayList), so you can get the count using `$MyArray.Count` and use `<% if $MyArray %>` as a shortcut for `<% if $MyArray.Count %>`.
- Other functionality from `ArrayList` such as filtering and sorting cannot be used on these arrays since they don't have keys to filter or sort against.
- Because arrays are no longer cast to a `DBField`, calling a `DBField` formatter on a getter that returns an array without a `$casting` entry now renders an empty string. For example, `$MyGetter.JSON` rendered JSON in CMS 5 but renders nothing in CMS 6. Return the encoded string from a separate getter instead (e.g. `$MyGetterJSON`), or declare a `$casting` type for the getter. Note that a getter with a `$casting` type can no longer be looped over.
- Arguments are now passed into getter methods when invoked in templates. For example, if a model has a `getMyField(...$args)` method and `$MyField(1,2,3)` is used in a template, the args `1, 2, 3` will be passed in to the `getMyField()` method.
- Values from template variables are passed into functions when used as arguments
- For example, `$doSomething($Title)` will pass the value of the `Title` property into the `doSomething()` method. Previously `"$Title"` would be passed as a string. See [template syntax](/developer_guides/templates/syntax/#variables) documentation for more details.
Expand Down
Loading