Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.
You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page
The SwitchType
displays a switch with Yes/No values.
Option | Type | Default | Description |
---|---|---|---|
choices | array | Choices with Yes/No values | Choices for switch type |
disabled | bool | false |
Whether Switch should be disabled or not |
None.
Add SwitchType
to your form.
<?php
use Symfony\Component\Form\AbstractType;
use PrestaShopBundle\Form\Admin\Type\SwitchType;
class SomeType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('switch', SwitchType::class, [
// Customized choices with ON/OFF instead of Yes/No
'choices' => [
'ON' => true,
'OFF' => false,
],
]);
}
}