Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

3.1 ClassInfo::implementorsOf


Go to End


413 Views

Avatar
timo

Community Member, 47 Posts

17 February 2015 at 3:57am

i am confused and don't get this to work.
here is a class : class Custom_HtmlEditorField_Toolbar extends Extension
it pushes a new radio-button to the link-dialog - popup on htmleditorfield.
also a sitetree- dropdown.

what i am trying to do is to add a checkbox, only visible when choosing the linkable-radio-button.
why is this checkbox hidden (display: none)???
any ideas?
thanks. timo.

class Custom_HtmlEditorField_Toolbar extends Extension{

	/**
	 * Aggiorna l'elenco delle possibili opzioni di link
	 * @param Form $form
	 * @return type
	 */
	public function updateLinkForm($form) {
		
		Requirements::javascript(LINKABLE_DATAOBJECTS_DIR . "/javascript/linkable-dataobjects.js");
		
		$fields = $form->Fields();
		/* @var $linkTipe CompositeField */
		$compositeField = $fields[1];
		/* @var $linkTipe OptionsetField */
		$linkTipe = $fields[1]->fieldByName("LinkType");
		
		$options = $linkTipe->getSource();
		
		$linkables = ClassInfo::implementorsOf('Linkable', 'replace_linkabledo');
		foreach ($linkables as $class) {
			
			$options[strtolower($class)] = $class::LinkLabel();
			$linkTipe->setSource($options);
			
			$replaceField = $fields[1];
			$checkbox = new CheckboxField('replace_linkabledo', 'Link mit DIV ersetzen?');
			$checkbox->addExtraClass('linkabledo', 'Linkable');
			$replaceField->push($checkbox);
			
			$dropdown = new DropdownField(strtolower($class), _t('HtmlEditorField.NEWS', $class::LinkLabel()), $class::get()->map('ID', 'Title'));
			$dropdown->addExtraClass('linkabledo');
			$compositeField->push($dropdown);
				
			
		}
		return $form;
	}
}