mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
ENH Take advantage of auto-scaffolded formfields for link (#190)
This commit is contained in:
parent
a51b65b336
commit
e279e5a0b6
@ -10,6 +10,7 @@ use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Forms\CompositeValidator;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\Forms\RequiredFields;
|
||||
use SilverStripe\Forms\SearchableDropdownField;
|
||||
use SilverStripe\Forms\TextField;
|
||||
|
||||
/**
|
||||
@ -47,7 +48,12 @@ class ElementContentExtension extends Extension
|
||||
|
||||
protected function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$fields->removeByName('HTML');
|
||||
// Note we explicitly use a SearchableDropdownField here so the behat test can rely on specific selectors
|
||||
$fields->removeByName(['HTML', 'MyPage', 'MyPageID']);
|
||||
$fields->addFieldToTab(
|
||||
'Root.Main',
|
||||
SearchableDropdownField::create('MyPageID', 'My page', SiteTree::get())->setIsLazyLoaded(false)
|
||||
);
|
||||
$fields->addFieldToTab('Root.Main', TextField::create('MyField', 'My Field'));
|
||||
$fields->addFieldToTab('Root.Main', NumericField::create('MyInt', 'My Int'));
|
||||
}
|
||||
|
@ -5,8 +5,6 @@ namespace SilverStripe\FrameworkTest\LinkField\Extensions;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\LinkField\Models\Link;
|
||||
use SilverStripe\LinkField\Form\LinkField;
|
||||
use SilverStripe\LinkField\Form\MultiLinkField;
|
||||
use SilverStripe\LinkField\Models\ExternalLink;
|
||||
|
||||
class CompanyExtension extends Extension
|
||||
@ -36,15 +34,6 @@ class CompanyExtension extends Extension
|
||||
|
||||
protected function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$fields->removeByName(['CompanyWebSiteLinkID', 'ManyCompanyWebSiteLinkID']);
|
||||
|
||||
$fields->addFieldsToTab(
|
||||
'Root.Main',
|
||||
[
|
||||
LinkField::create('CompanyWebSiteLink', 'Company Website link')
|
||||
->setAllowedTypes([ExternalLink::class]),
|
||||
MultiLinkField::create('ManyCompanyWebSiteLink', 'Multiple Company Website link'),
|
||||
]
|
||||
);
|
||||
$fields->dataFieldByName('CompanyWebSiteLink')->setAllowedTypes([ExternalLink::class]);
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
namespace SilverStripe\FrameworkTest\LinkField\Extensions;
|
||||
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\LinkField\Form\LinkField;
|
||||
use SilverStripe\LinkField\Form\MultiLinkField;
|
||||
use SilverStripe\LinkField\Models\Link;
|
||||
use SilverStripe\LinkField\Models\EmailLink;
|
||||
use SilverStripe\LinkField\Models\PhoneLink;
|
||||
@ -39,18 +37,10 @@ class ElementContentExtension extends Extension
|
||||
|
||||
protected function updateCMSFields($fields)
|
||||
{
|
||||
$fields->removeByName(['OneLinkID', 'ManyLinks']);
|
||||
$fields->addFieldsToTab(
|
||||
'Root.Main',
|
||||
[
|
||||
LinkField::create('OneLink', 'Single Link')
|
||||
->setAllowedTypes([
|
||||
SiteTreeLink::class,
|
||||
EmailLink::class,
|
||||
PhoneLink::class
|
||||
]),
|
||||
MultiLinkField::create('ManyLinks', 'Multiple Links'),
|
||||
],
|
||||
);
|
||||
$fields->dataFieldByName('OneLink')->setAllowedTypes([
|
||||
SiteTreeLink::class,
|
||||
EmailLink::class,
|
||||
PhoneLink::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class LinkPageExtension extends Extension
|
||||
|
||||
protected function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$fields->removeByName(['Content', 'HasOneLinkID', 'HasManyLinksID']);
|
||||
$fields->removeByName(['Content']);
|
||||
|
||||
$fields->addFieldsToTab(
|
||||
'Root.Main',
|
||||
|
Loading…
Reference in New Issue
Block a user