Changing class of select by $renderer->wrappers

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
Ja
Člen | 260
+
0
-

It's possible to change the class of input text

<?php
$renderer->wrappers['control']['.text'] = 'form-control';
?>

but I cannot figure out how to add class to select, this doesn't work

<?php
$renderer->wrappers['control']['.select'] = 'form-control';
?>

any hint? :)
thanks!

Casper
Člen | 253
+
0
-

You can see possible wrappers in DefaultFormRenderer. There is no .select in there. So I guess, you cannot do this by wrappers.

KingKoca
Člen | 25
+
0
-

But you can create your own renderer by extending DefaultFormRenderer class and override init() function, where you can enable adding class to select by $wrappers[‚control‘][‚.select‘]. I did it like this:

protected function init()
{
    parent::init();

    $wrapper = & $this->wrappers['control'];
    foreach ($this->form->getControls() as $control) {
        // add class to selectbox
        if($control instanceof \Nette\Forms\Controls\SelectBox){
            $control->controlPrototype->class($wrapper['.select'],TRUE);
        }
    }
}
KingKoca
Člen | 25
+
+1
-

Is there any way to to that in version 2.3? There is no init method anymore.

Thanks