-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11057 from creative-commoners/pulls/5/selectorfield
NEW SearchableDropdownField
- Loading branch information
Showing
7 changed files
with
873 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace SilverStripe\Forms; | ||
|
||
use SilverStripe\Dev\Deprecation; | ||
use SilverStripe\Forms\DropdownField; | ||
use SilverStripe\ORM\DataList; | ||
|
||
class SearchableDropdownField extends DropdownField | ||
{ | ||
use SearchableDropdownTrait; | ||
|
||
// This needs to be defined on the class, not the trait, otherwise there is a PHP error | ||
protected $schemaComponent = 'SearchableDropdownField'; | ||
|
||
public function __construct( | ||
string $name, | ||
string $title, | ||
DataList $source, | ||
mixed $value = null, | ||
string $labelField = 'Title' | ||
) { | ||
parent::__construct($name, $title, $source, $value); | ||
$this->setLabelField($labelField); | ||
$this->addExtraClass('ss-searchable-dropdown-field'); | ||
$this->setHasEmptyDefault(true); | ||
} | ||
|
||
/** | ||
* @param string $string | ||
* @return $this | ||
* | ||
* @deprecated 5.2.0 Use setPlaceholder() instead | ||
*/ | ||
public function setEmptyString($string) | ||
{ | ||
Deprecation::notice('5.2.0', 'Use setPlaceholder() instead'); | ||
return parent::setEmptyString($string); | ||
} | ||
} |
Oops, something went wrong.