public function optionlist($config = array())
    {
        $translator = $this->getObject('translator');

        $config = new ObjectConfigJson($config);
        $config->append(array(
            'prompt'    => '- '.$translator->translate('Select').' -',
            'deselect'  => false,
            'options'   => array(),
            'select2'   => true,
            'attribs'   => array(),
        ));

        if ($config->deselect && !$config->attribs->multiple)
        {
            $deselect = $this->option(array('value' => '', 'label' => $config->prompt));
            $options  = $config->options->toArray();
            array_unshift($options, $deselect);
            $config->options = $options;
        }

        if ($config->attribs->multiple && $config->name && substr($config->name, -2) !== '[]') {
            $config->name .= '[]';
        }

        $html = '';

        if ($config->select2)
        {
            if (!$config->name) {
                $config->attribs->append(array(
                    'id' => 'select2-element-'.mt_rand(1000, 100000)
                ));
            }
            
            if ($config->deselect) {
                $config->attribs->append(array(
                    'data-placeholder' => $config->prompt
                ));
            }

            $config->append(array(
                'select2_options' => array(
                    'element' => $config->attribs->id ? '#'.$config->attribs->id : 'select[name=\"'.$config->name.'\"]',
                    'options' => array(
                        'allowClear'  => $config->deselect
                    )

                )
            ));

            $html .= $this->createHelper('behavior')->select2($config->select2_options);
        }

        $html .= parent::optionlist($config);

        return $html;
    }