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

PATCH: fix issue #8691 - DB Boolean Search #9893

Merged
merged 1 commit into from
Mar 23, 2021
Merged
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
6 changes: 3 additions & 3 deletions src/ORM/FieldType/DBBoolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public function scaffoldSearchField($title = null)
{
$anyText = _t(__CLASS__ . '.ANY', 'Any');
$source = [
'' => $anyText,
1 => _t(__CLASS__ . '.YESANSWER', 'Yes'),
0 => _t(__CLASS__ . '.NOANSWER', 'No')
];

$field = new DropdownField($this->name, $title, $source);
$field->setEmptyString("($anyText)");
return $field;
return (new DropdownField($this->name, $title, $source))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would using the injector be better instead of instantiating the class directly?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be. Unfortunately, most DB fields do still circumvent Injector in their scaffoldSearchFields() implementations. I think it's just code from 3.x that survived the upgrade in tact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would... Do you mean:

DropdownField::create()

Happy to change it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say let's do that in a separate PR that applies injector to all these core implementations, rather than just do a one-off. The problem is, if we have some fields that are responding to Injector overrides and some that aren't, it just creates a confusing dev experience. In my quick assessment, it looks like most fields are still using new, so I'd advocate for just going with the pack, here.

Consistent use of Injector in a separate body of work would be sweet, though.

->setEmptyString($anyText);
}

public function nullValue()
Expand Down