silverstripe-cms/code/Forms/AnchorLinkFormFactory.php
2017-09-20 13:35:25 +12:00

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' ]);
}
}