Get wrapping container of control prototype

7 days ago

gebeer
Member | 3
+
0
-

Hello,
in a custom renderer I need to assign a class attribute to a specific control type's container.

Therefore I need to get the control's wrapping container HTML template.

In my render() method I have this

foreach ($form->getControls() as $control) {
    if ($control instanceof Controls\Button) {
        $control->getControlPrototype()->getWrapper()->addClass('myClass'); // dummy method getWrapper() - is there sth like this?
    }
}

I searched the API ref but couldn't find a method for this in https://api.nette.org/…ls.Html.html

In the __construct() method each control gets a wrapper like this

$this->wrappers['control']['container'] = 'div class=col-sm-10';

I cannot apply the class to the container in the __construct() method because this would apply it to all controls

Also tried to search from the form's elemtPrototype downwards. But

$form->getElementPrototype()->getChildren()

returns an empty array.

And the Basecontrol class (https://api.nette.org/…Control.html) also has no Method to get to the wrapping container.

So how could I accomplish this?