Auto-scaffolding for has_one form fields creates an instance of SearchableDropdownField by passing:
SearchableDropdownField::create($this->name, $title, $list, $labelField)
The signature for the SearchableDropdownField constructor expects:
string $name, ?string $title = null, ?DataList $source = null, mixed $value = null, string $labelField = 'Title'
So the call is missing $value. This leads to $value being set to $labelField, which is 'Title'.
Not a big deal, since the scaffolding will set the value later again. But it leads to warnings in the php log:
Could not determine value in SilverStripe|Forms|SearchableDropdownField: :getValueArray()
Module version(s) affected
5.2.13
Description
Auto-scaffolding for has_one form fields creates an instance of SearchableDropdownField by passing:
SearchableDropdownField::create($this->name, $title, $list, $labelField)
The signature for the SearchableDropdownField constructor expects:
string $name, ?string $title = null, ?DataList $source = null, mixed $value = null, string $labelField = 'Title'
So the call is missing $value. This leads to $value being set to $labelField, which is 'Title'.
Not a big deal, since the scaffolding will set the value later again. But it leads to warnings in the php log:
Since this is also affecting my idea for a solution of https://github.com/silverstripe/silverstripe-framework/issues/11293 I'll create a separate fix and pull request for this issue.
How to reproduce
Given ModelA has_one ModelB and ModelB has_many ModelA:
Check Error Log.
Possible Solution
add
null
as value when calling SearchableDropdownField::createAdditional Context
No response
Validations
silverstripe/installer
(with any code examples you've provided)PRs