/** * @inheritdoc */ public function fileInput($options = []) { $options = array_merge($this->inputOptions, $options); $options['wrapperOptions']['tag'] = isset($options['wrapperOptions']) && isset($options['wrapperOptions']['tag']) ? $options['wrapperOptions']['tag'] : 'div'; $this->_setWrapperOptions($options, 'input input-file'); // Set template $this->template = $this->fileInputTemplate; // Button $btnOptions = ArrayHelper::remove($options, 'buttonOptions', []); $btnTag = ArrayHelper::remove($btnOptions, 'tag', 'span'); $btnContent = ArrayHelper::remove($btnOptions, 'content', 'Browse'); Html::addCssClass($btnOptions, 'button'); $this->parts['{beginButton}'] = Html::beginTag($btnTag, $btnOptions); $this->parts['{contentButton}'] = $btnContent; $this->parts['{endButton}'] = Html::endTag($btnTag); // Placeholder input $phrOptions = ArrayHelper::remove($options, 'placeholderOptions', []); $phrOptions['readonly'] = 'readonly'; $placeholder = ArrayHelper::remove($options, 'placeholder'); if ($placeholder !== null) { $phrOptions['placeholder'] = $placeholder; } $this->parts['{placeholder}'] = Html::input('text', null, null, $phrOptions); // Onchange $onchange = 'this.parentNode.nextSibling.value = this.value'; $options['onchange'] = isset($options['onchange']) ? $options['onchange'] : $onchange; return parent::fileInput($options); }