Skip to content

Commit

Permalink
Merge pull request #188 from creative-commoners/pulls/1/elemental-dro…
Browse files Browse the repository at this point in the history
…pdown

NEW Add models for testing elemental searchable fields
  • Loading branch information
GuySartorelli authored Jun 21, 2024
2 parents e44c1b4 + 1513d51 commit 3bbd075
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions code/elemental/ElementalSearchableFieldsBlock.php
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 3bbd075

Please sign in to comment.