Skip to content

With UploadInpu setHtmlAttribute("class",***) doesn't working #22

@matlad

Description

@matlad

The problem is that here, the class is overwritten and not added. In addition, I think it would be better set class to wrapper (from which you can easily get to the input).

$control->class = 'custom-file-input';

Solution: something like this

public function getControl(){
	$control = parent::getControl();
        BootstrapUtils::standardizeClass($control);
        $wrapperClass = $control->class;
        $wrapperClass[] = 'custom-file';
        $control->class = 'custom-file-input';
        
		$el = Html::el('div', ['class' => $wrapperClass]);
		$el->addHtml($control);
		$el->addHtml(
			Html::el('label', [
				'class' => ['custom-file-label'],
				'for'   => $this->getHtmlId(),
			])->setText($this->buttonCaption)
		);
	return $el;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions