diff --git a/src/BootstrapFormRenderer.php b/src/BootstrapFormRenderer.php index 5005fde..2383ca5 100644 --- a/src/BootstrapFormRenderer.php +++ b/src/BootstrapFormRenderer.php @@ -287,7 +287,7 @@ protected static function bootstrap4(Nette\Forms\Container $container): void $type = $control->getOption('type'); if ($control instanceof Nette\Forms\Controls\Button) { $control->renderAsButton(); - + if ($control->getValidationScope() !== null) { $control->getControlPrototype()->addClass('btn btn-outline-secondary'); } else { @@ -296,7 +296,16 @@ protected static function bootstrap4(Nette\Forms\Container $container): void } } elseif (in_array($type, ['checkbox', 'radio'], true)) { - if ($control instanceof Nette\Forms\Controls\Checkbox) { + + if ($control->getOption('switch') === true) { + $control->getContainerPrototype() + ->setName('div') + ->addClass('form-check form-switch'); + + $control->getControlPrototype() + ->addClass('form-check-input'); + } + elseif ($control instanceof Nette\Forms\Controls\Checkbox) { $control->getLabelPrototype()->addClass('form-check-label'); } else { $control->getItemLabelPrototype()->addClass('form-check-label');