mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
Merge pull request #188 from creative-commoners/pulls/1/elemental-dropdown
NEW Add models for testing elemental searchable fields
This commit is contained in:
commit
3bbd075584
48
code/elemental/ElementalSearchableFieldsBlock.php
Normal file
48
code/elemental/ElementalSearchableFieldsBlock.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\FrameworkTest\Elemental\Model;
|
||||||
|
|
||||||
|
use DNADesign\Elemental\Models\BaseElement;
|
||||||
|
use SilverStripe\Forms\SearchableDropdownField;
|
||||||
|
use SilverStripe\Forms\SearchableMultiDropdownField;
|
||||||
|
use SilverStripe\FrameworkTest\Model\Company;
|
||||||
|
|
||||||
|
class ElementalSearchableFieldsBlock extends BaseElement
|
||||||
|
{
|
||||||
|
private static $table_name = 'ElementalSearchableFieldsBlock';
|
||||||
|
|
||||||
|
private static string $singular_name = 'SearchableFields Block';
|
||||||
|
|
||||||
|
private static string $plural_name = 'SearchableFields Blocks';
|
||||||
|
|
||||||
|
private static $has_one = [
|
||||||
|
'Company' => 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user