Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX DBForeignKey scaffolding missing parameter #11295

Merged

Conversation

johannesx75
Copy link
Contributor

@johannesx75 johannesx75 commented Jun 27, 2024

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'.

Manual testing steps

Given ModelA has_one ModelB and ModelB has_many ModelA:

  • Open ModelB in Model Admin
  • Go to the ModelA Tab
  • Click on Add new Model A
  • Check Error Log.

Prior to this fix it would contain a warning:

Could not determine value in SilverStripe|Forms|SearchableDropdownField: :getValueArray()

Issues

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@emteknetnz emteknetnz merged commit 1943f9d into silverstripe:5.2 Jul 3, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants