Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

issue with select2

i have been trying to use the select2 form type, the problem is that additional options like "maximumSelectionLength" wont work
$fields['states'] = array('type' => 'select2', 'maximumSelectionLength'=>5,'maximumInputLength'=>3);
it outputs the select2 but the maximumSelectionLength does not take effect.
any help please


  • edited October 2019

    Does it work if you attach data attributes to the element like in the following:

    $fields['states'] = array('type' => 'select2', 'data' => array('maximum-selection-length' => 5, 'maximum-input-length'=>3));
  • Sorry for the delayed response, Let me give that a try

  • edited October 2019

    Thanks for the code but I tried it and it still did not work.
    $fields['states'] = array('type' => 'select2', 'data' => array('maximum-selection-length' => 2, 'maximum-input-length'=>3));

  • Another thing you could try is adding the following to the fuel/application/config/custom_fields.php to overwrite the existing configuration for the select2 custom field:

    $fields['select2'] = array(
        'class'     => array(FUEL_FOLDER => 'Fuel_custom_fields'),
        'function'  => 'select2',
        'js' => array(
            FUEL_FOLDER => array(
        'js_exec_order' => 1,
        'js_function' => 'fuel.fields.select2',
            'js_params' => array('maximumSelectionLength' => 5, 'maximumInputLength' => 3),
        'css' => array(
            FUEL_FOLDER => array(

    Note the js_params addition to the configuration. That gets converted to a JSON object which gets passed to the select2 as a configuration object in the custom_fields.js select2 function.

Sign In or Register to comment.