How to create a new smartyFBV function and a case for a new type

Hi!

I’m trying to create a new slider item type to use in the Review Forms I create, and by doing so I had to make a new smartyFBV function for the range template inside FormBuilderVocabulary.php. However, I’m struggling to add this new function to the FormBuilderVocabulary through the GenericPlugin that I made. I tried using the TemplateManager::display hook and then attach the slider information through the

$templateMgr-> assign()

However, that didn’t work. This is the function that I added to FormBuilderVocabulary.php as well as another change I had to do to allow it to have a case statement for type ‘range’;

public function _smartyFBVRangeInput($params, $smarty)
    {
        // Set up the parameters for the range input
        $params['name'] = $params['name'] ?? $params['id'];
        $rangeInputParams = '';

        // Assign necessary params for the range input element
        $smarty->assign([
            'FBV_id' => $params['id'],
            'FBV_min' => $params['min'] ?? 0,
            'FBV_max' => $params['max'] ?? 100,
            'FBV_value' => $params['value'] ?? 50,
            'FBV_class' => $params['class'] ?? null,
            'FBV_step' => $params['step'] ?? 1
        ]);

        return $smarty->fetch('form/rangeInput.tpl');
    }

and this change in the function inside FormBuilderVocabulary.php

public function smartyFBVElement($params, $smarty, $content = null)
case 'range':
                $content = $this->_smartyFBVRangeInput($params, $smarty); // Create a method to handle range input
                break;

I want to implement these changes without modifying the core code file FormBuilderVocabulary.php, any help regarding how I can achieve this through the plugin that I have created would be appreciated!

Hi @bilalelkhouly,

Could you please note which version you’re working from (e.g. 3.3.0-13)?

-Roger
PKP Team