• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 Forum Chooser for single forum


Well-known member

In the Options page of one of my add-ons I can get a Forum Chooser to work properly but only for multiple forum selection. Here's the PHP code:


namespace Andy\BirthdayThread\Option;

class ForumChooser extends \XF\Option\AbstractOption
    public static function renderSelect(\XF\Entity\Option $option, array $htmlParams)
        /** @var \XF\Repository\Node $nodeRepo */
        $nodeRepo = \XF::repository('XF:Node');

        $choices = $nodeRepo->getNodeOptionsData(true, 'Forum', 'option');
        $choices = array_map(function($v) {
            $v['label'] = \XF::escapeString($v['label']);
            return $v;
        }, $choices);

        $controlOptions = self::getControlOptions($option, $htmlParams);
        $controlOptions['multiple'] = true;

        $rowOptions = self::getRowOptions($option, $htmlParams);

        return self::getTemplater()->formSelectRow($controlOptions, $choices, $rowOptions);
When I change the following code:

$controlOptions['multiple'] = true;

from "true" to "false" I'm able to select just one forum from the drop down menu in the Options page, but I get the following error when I try to save the Options:



Well-known member
Hmm ... \XF\Option\Forum::renderSelectMultiple seems to work just fine for multiple select, why do you want to create your own callback to handle the option?

If you want a single select use \XF\Option\Forum::renderSelect instead
Last edited: