|
10 | 10 | use Contributte\Datagrid\Traits\TButtonTitle; |
11 | 11 | use Contributte\Datagrid\Traits\TButtonTryAddIcon; |
12 | 12 | use Nette\Forms\Container; |
| 13 | +use Nette\Forms\Controls\BaseControl; |
| 14 | +use Nette\Forms\Controls\SubmitButton; |
13 | 15 | use Nette\SmartObject; |
14 | 16 | use Nette\Utils\ArrayHash; |
15 | 17 | use Nette\Utils\Html; |
@@ -178,20 +180,24 @@ public function addControlsClasses(Container $container): void |
178 | 180 | foreach ($container->getControls() as $key => $control) { |
179 | 181 | switch ($key) { |
180 | 182 | case 'submit': |
181 | | - $control->setValidationScope([$container]); |
182 | | - $control->setAttribute('class', 'btn btn-xs btn-primary'); |
| 183 | + if ($control instanceof SubmitButton) { |
| 184 | + $control->setValidationScope([$container]); |
| 185 | + $control->setHtmlAttribute('class', 'btn btn-xs btn-primary'); |
| 186 | + } |
183 | 187 |
|
184 | 188 | break; |
185 | 189 |
|
186 | 190 | case 'cancel': |
187 | | - $control->setValidationScope([]); |
188 | | - $control->setAttribute('class', 'btn btn-xs btn-danger'); |
| 191 | + if ($control instanceof SubmitButton) { |
| 192 | + $control->setValidationScope([]); |
| 193 | + $control->setHtmlAttribute('class', 'btn btn-xs btn-danger'); |
| 194 | + } |
189 | 195 |
|
190 | 196 | break; |
191 | 197 |
|
192 | 198 | default: |
193 | | - if ($control->getControlPrototype()->getAttribute('class') === null) { |
194 | | - $control->setAttribute('class', 'form-control form-control-sm'); |
| 199 | + if ($control instanceof BaseControl && $control->getControlPrototype()->getAttribute('class') === null) { |
| 200 | + $control->setHtmlAttribute('class', 'form-control form-control-sm'); |
195 | 201 | } |
196 | 202 |
|
197 | 203 | break; |
|
0 commit comments