From 4c984557a0add31960937395ecafd2569f647255 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Sat, 16 Mar 2024 14:24:39 +0100 Subject: [PATCH] Add method to remove field from settings form --- src/Form/AbstractSettingsExtension.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Form/AbstractSettingsExtension.php b/src/Form/AbstractSettingsExtension.php index a444635a..5c66a752 100644 --- a/src/Form/AbstractSettingsExtension.php +++ b/src/Form/AbstractSettingsExtension.php @@ -35,6 +35,16 @@ public function addWithDefaultCheckbox(FormBuilderInterface $builder, string $ch return $this; } + public function removeWithDefaultCheckbox(FormBuilderInterface $builder, string $child): self + { + $builder->remove($child); + if (!$this->isDefaultForm($builder)) { + $builder->remove($child . '___' . Settings::DEFAULT_KEY); + } + + return $this; + } + protected function isDefaultForm(FormBuilderInterface $builder): bool { return !$builder->getOption('show_default_checkboxes', true);