Skip to content

Commit

Permalink
Merge pull request #1277 from tomudding/fix/broken-company-package-fo…
Browse files Browse the repository at this point in the history
…rms-for-non-localisable-variant

Fix package forms not validating due to localisable dependency
  • Loading branch information
tomudding authored Nov 17, 2021
2 parents 9b63263 + c11286f commit d7621a3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
49 changes: 25 additions & 24 deletions module/Application/src/Form/Localisable.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,36 @@ abstract class Localisable extends Form implements InputFilterProviderInterface
*/
private Translator $translator;

public function __construct(Translator $translator)
public function __construct(Translator $translator, bool $addElements = true)
{
parent::__construct();

$this->translator = $translator;

$this->add(
[
'name' => 'language_dutch',
'type' => Checkbox::class,
'options' => [
'label' => $this->getTranslator()->translate('Enable Dutch Translations'),
'checked_value' => '1',
'unchecked_value' => '0',
],
]
);
if ($addElements) {
$this->add(
[
'name' => 'language_dutch',
'type' => Checkbox::class,
'options' => [
'label' => $this->getTranslator()->translate('Enable Dutch Translations'),
'checked_value' => '1',
'unchecked_value' => '0',
],
]
);

$this->add(
[
'name' => 'language_english',
'type' => Checkbox::class,
'options' => [
'label' => $this->getTranslator()->translate('Enable English Translations'),
'checked_value' => '1',
'unchecked_value' => '0',
],
]
);
$this->add(
[
'name' => 'language_english',
'type' => Checkbox::class,
'options' => [
'label' => $this->getTranslator()->translate('Enable English Translations'),
'checked_value' => '1',
'unchecked_value' => '0',
],
]
);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion module/Company/src/Form/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Package extends LocalisableForm implements InputFilterProviderInterface

public function __construct(Translator $translator, string $type)
{
parent::__construct($translator);
parent::__construct($translator, ('featured' === $type));
$this->type = $type;
$this->setAttribute('method', 'post');

Expand Down

0 comments on commit d7621a3

Please sign in to comment.