Implement snip hiding
This commit is contained in:
@ -28,7 +28,8 @@ class SnipType extends AbstractType
|
||||
'attr' => ['rows' => 20],
|
||||
'mapped' => false,
|
||||
])
|
||||
->add('public')
|
||||
->add('public', SwitchType::class)
|
||||
->add('visible', SwitchType::class)
|
||||
;
|
||||
}
|
||||
|
||||
|
22
src/Form/SwitchType.php
Normal file
22
src/Form/SwitchType.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\Form\FormView;
|
||||
|
||||
class SwitchType extends AbstractType
|
||||
{
|
||||
public function getParent(): string
|
||||
{
|
||||
return CheckboxType::class;
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
$view->vars['label_attr']['class'] = trim(($view->vars['label_attr']['class'] ?? '') . ' checkbox-switch');
|
||||
$view->vars['required'] = false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user