From cfab624fba051c5184f09bed76e00e65c82907b1 Mon Sep 17 00:00:00 2001 From: DidierLmn Date: Wed, 4 Mar 2020 07:49:25 +0100 Subject: [PATCH] Theming fixes (#39) * Fix admin views with inputsizes * Fix form theming issues * Pass button type class to formfactory --- Form/Type/DoubleButtonType.php | 3 +++ FormFactory/FormBuilderFactory.php | 14 ++++++++++++-- composer.json | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Form/Type/DoubleButtonType.php b/Form/Type/DoubleButtonType.php index 6d9fee5..8cee956 100644 --- a/Form/Type/DoubleButtonType.php +++ b/Form/Type/DoubleButtonType.php @@ -15,6 +15,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder ->add('button_'.$option['key'], $buttonType, [ 'label' => $option['label'], + 'attr' => [ + 'class' => $option['class'] + ] ]); } } diff --git a/FormFactory/FormBuilderFactory.php b/FormFactory/FormBuilderFactory.php index cf5f5d2..0a66889 100644 --- a/FormFactory/FormBuilderFactory.php +++ b/FormFactory/FormBuilderFactory.php @@ -361,7 +361,8 @@ private function getSelectedValue($select) public function setFieldSinglebutton($form, $key, $elem): array { $action = $this->getSelectedValue($elem->fields->buttonaction->value); - $this->createButton($form, $action, $key, $elem->fields->buttonlabel->value); + $style = $this->getSelectedValue($elem->fields->buttontype->value); + $this->createButton($form, $action, $key, $elem->fields->buttonlabel->value, $style); return [ 'name' => 'button_' . $key, @@ -378,9 +379,11 @@ public function setFieldSinglebutton($form, $key, $elem): array public function setFieldDoublebutton($form, $key, $elem): array { $action1 = $this->getSelectedValue($elem->fields->button1action->value); + $style1 = $this->getSelectedValue($elem->fields->button1type->value); $buttonType1 = $this->getButtonType($action1); $action2 = $this->getSelectedValue($elem->fields->button2action->value); + $style2 = $this->getSelectedValue($elem->fields->button2type->value); $buttonType2 = $this->getButtonType($action2); $form->add('double_button_' . $key, DoubleButtonType::class, [ @@ -389,11 +392,13 @@ public function setFieldDoublebutton($form, $key, $elem): array 'button_type' => $buttonType1, 'key' => '1_' . $key, 'label' => $elem->fields->button1label->value, + 'class' => $style1, ], [ 'button_type' => $buttonType2, 'key' => '2_' . $key, 'label' => $elem->fields->button2label->value, + 'class' => $style2, ] ] ]); @@ -409,13 +414,18 @@ public function setFieldDoublebutton($form, $key, $elem): array * @param $action * @param $key * @param $value + * @param $style */ - private function createButton(SymfonyFormBuilder $form, $action, $key, $value): void + private function createButton(SymfonyFormBuilder $form, $action, $key, $value, $style = null): void { $buttonType = $this->getButtonType($action); $form->add('button_' . $key, $buttonType, [ 'label' => $value, + 'attr' => [ + 'class' => $style, + ] + ]); } diff --git a/composer.json b/composer.json index 7e07457..7740f5e 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ ], "require": { "php": "^7.1", + "symfony/symfony": "3.4.*", "sonata-project/block-bundle": "^3.14", "gregwar/captcha-bundle": "^2.0", "sonata-project/admin-bundle": "^3.38.0",