Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.3' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Feb 10, 2023
2 parents d9dd7d3 + 4d08e6d commit f9ce7fd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
"dev-main": "4.4.x-dev"
}
},
"config": {
"allow-plugins": {
"*/*": false
}
},
"scripts": {
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
"check-cs": "@fix-cs --dry-run",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/Content/View/Filter/ContentCreateViewFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public function handleContentCreateForm(FilterViewBuilderParametersEvent $event)
$contentCreateData = $this->resolveContentCreateData($contentType, $location, $languageCode);
$form = $this->resolveContentCreateForm(
$contentCreateData,
$languageCode
$languageCode,
false
);

$event->getParameters()->add(['form' => $form->handleRequest($request)]);
Expand Down Expand Up @@ -123,13 +124,15 @@ private function resolveContentCreateData(
*/
private function resolveContentCreateForm(
ContentCreateData $contentCreateData,
string $languageCode
string $languageCode,
bool $autosaveEnabled = true
): FormInterface {
return $this->formFactory->create(ContentEditType::class, $contentCreateData, [
'languageCode' => $languageCode,
'mainLanguageCode' => $languageCode,
'contentCreateStruct' => $contentCreateData,
'drafts_enabled' => true,
'autosave_enabled' => $autosaveEnabled,
]);
}
}
Expand Down
45 changes: 26 additions & 19 deletions src/lib/Form/Type/Content/ContentEditType.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,32 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add('publish', SubmitType::class, ['label' => 'Publish']);

if ($options['drafts_enabled']) {
$builder
->add('saveDraft', SubmitType::class, [
'label' => /** @Desc("Save draft") */ 'save_draft',
'attr' => ['formnovalidate' => 'formnovalidate'],
])
->add('cancel', SubmitType::class, [
'label' => /** @Desc("Cancel") */ 'cancel',
'attr' => ['formnovalidate' => 'formnovalidate'],
])
->add('autosave', SubmitType::class, [
'label' => /** @Desc("Autosave") */ 'autosave',
'attr' => [
'hidden' => true,
'formnovalidate' => 'formnovalidate',
],
'translation_domain' => 'content_edit',
]);
$builder->addEventSubscriber(new SuppressValidationSubscriber());
if (!$options['drafts_enabled']) {
return;
}

$builder
->add('saveDraft', SubmitType::class, [
'label' => /** @Desc("Save draft") */ 'save_draft',
'attr' => ['formnovalidate' => 'formnovalidate'],
])
->add('cancel', SubmitType::class, [
'label' => /** @Desc("Cancel") */ 'cancel',
'attr' => ['formnovalidate' => 'formnovalidate'],
]);

if ($options['autosave_enabled']) {
$builder->add('autosave', SubmitType::class, [
'label' => /** @Desc("Autosave") */ 'autosave',
'attr' => [
'hidden' => true,
'formnovalidate' => 'formnovalidate',
],
'translation_domain' => 'content_edit',
]);
}

$builder->addEventSubscriber(new SuppressValidationSubscriber());
}

public function configureOptions(OptionsResolver $resolver)
Expand All @@ -74,6 +80,7 @@ public function configureOptions(OptionsResolver $resolver)
'contentCreateStruct' => null,
'contentUpdateStruct' => null,
'drafts_enabled' => false,
'autosave_enabled' => true,
'data_class' => ContentStruct::class,
'translation_domain' => 'ezplatform_content_forms_content',
'intent' => 'update',
Expand Down

0 comments on commit f9ce7fd

Please sign in to comment.