Skip to content

Commit

Permalink
Theming fixes (#39)
Browse files Browse the repository at this point in the history
* Fix admin views with inputsizes

* Fix form theming issues

* Pass button type class to formfactory
  • Loading branch information
DidierLmn authored Mar 4, 2020
1 parent 1836456 commit cfab624
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Form/Type/DoubleButtonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('button_'.$option['key'], $buttonType, [
'label' => $option['label'],
'attr' => [
'class' => $option['class']
]
]);
}
}
Expand Down
14 changes: 12 additions & 2 deletions FormFactory/FormBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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, [
Expand All @@ -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,
]
]
]);
Expand All @@ -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,
]

]);
}

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit cfab624

Please sign in to comment.