setTitleField('MenuTitle') ->setHasEmptyDefault(true), TextField::create( 'Description', _t(__CLASS__.'.LINKDESCR', 'Link description') ), CheckboxField::create( 'TargetBlank', _t(__CLASS__.'.LINKOPENNEWWIN', 'Open in new window/tab') ), ]); if ($context['RequireLinkText']) { $fields->insertAfter('PageID', TextField::create('Text', _t(__CLASS__.'.LINKTEXT', 'Link text'))); } $this->extend('updateFormFields', $fields, $controller, $name, $context); return $fields; } protected function getValidator($controller, $name, $context) { if ($context['RequireLinkText']) { return RequiredFields::create('Text'); } return null; } }