diff --git a/code/form/WidgetAreaEditor.php b/code/form/WidgetAreaEditor.php index 4edc40f..a2bac4a 100644 --- a/code/form/WidgetAreaEditor.php +++ b/code/form/WidgetAreaEditor.php @@ -35,14 +35,20 @@ class WidgetAreaEditor extends FormField { * @return ArrayList */ public function AvailableWidgets() { - $widgets= new ArrayList(); - + foreach($this->widgetClasses as $widgetClass) { $classes = ClassInfo::subclassesFor($widgetClass); array_shift($classes); foreach($classes as $class) { - $widgets->push(singleton($class)); + + if (!empty($class::$only_available_in) && is_array($class::$only_available_in)){ + if(in_array($this->Name, $class::$only_available_in)) { + $widgets->push(singleton($class)); + } + }else { + $widgets->push(singleton($class)); + } } }