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

NEW Add models for testing elemental searchable fields #188

Merged
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
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';
GuySartorelli marked this conversation as resolved.
Show resolved Hide resolved

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;
}
}