mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
28 lines
757 B
PHP
28 lines
757 B
PHP
|
<?php
|
||
|
|
||
|
namespace SilverStripe\CMS\Forms;
|
||
|
|
||
|
class AnchorLinkFormFactory extends InternalLinkFormFactory
|
||
|
{
|
||
|
protected function getFormFields($controller, $name, $context)
|
||
|
{
|
||
|
$fields = parent::getFormFields($controller, $name, $context);
|
||
|
|
||
|
// Ensure current page is selected
|
||
|
$pageIDField = $fields->dataFieldByName('PageID');
|
||
|
$pageIDField->setValue((int)$context['PageID']);
|
||
|
|
||
|
// Get anchor selector field
|
||
|
$fields->insertAfter(
|
||
|
'PageID',
|
||
|
AnchorSelectorField::create('Anchor', _t(__CLASS__.'.ANCHORVALUE', 'Anchor'))
|
||
|
);
|
||
|
return $fields;
|
||
|
}
|
||
|
|
||
|
public function getRequiredContext()
|
||
|
{
|
||
|
return array_merge(parent::getRequiredContext(), [ 'PageID' ]);
|
||
|
}
|
||
|
}
|