diff --git a/code/elemental/ElementalSearchableFieldsBlock.php b/code/elemental/ElementalSearchableFieldsBlock.php new file mode 100644 index 0000000..60943ba --- /dev/null +++ b/code/elemental/ElementalSearchableFieldsBlock.php @@ -0,0 +1,48 @@ + Company::class, + ]; + + private static $many_many = [ + 'Companys' => Company::class, + ]; + + public function getCMSFields() + { + $fields = parent::getCMSFields(); + $fields->removeByName('CompanyID'); + $fields->addFieldToTab('Root.Main', SearchableDropdownField::create( + 'CompanyID', + 'Company', + Company::get() + ) + ->setLabelField('Name') + ->setIsLazyLoaded(true) + ); + $fields->addFieldToTab('Root.Main', SearchableMultiDropdownField::create( + 'Companys', + 'Companys', + Company::get() + ) + ->setLabelField('Name') + ->setIsLazyLoaded(true) + ); + return $fields; + } +}