silverstripe-cms/code/Forms/AnchorLinkFormFactory.php

28 lines
757 B
PHP
Raw Normal View History

2017-09-05 04:38:38 +02:00
<?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' ]);
}
}