Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-902: Fixed field groups in content on the fly edit #1886

Merged
merged 1 commit into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"symfony/yaml": "^5.0",
"jms/translation-bundle": "^1.5",
"ezsystems/ezplatform-kernel": "^1.3@dev",
"ezsystems/ezplatform-content-forms": "^1.0@dev",
"ezsystems/ezplatform-content-forms": "^1.3@dev",
"ezsystems/ezplatform-design-engine": "^3.0@dev",
"ezsystems/ezplatform-user": "^2.0@dev",
"ezsystems/ezplatform-richtext": "^2.0@dev",
Expand Down
12 changes: 12 additions & 0 deletions src/bundle/Controller/ContentOnTheFlyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use EzSystems\EzPlatformContentForms\Data\Mapper\ContentUpdateMapper;
use EzSystems\EzPlatformContentForms\Form\ActionDispatcher\ActionDispatcherInterface;
use EzSystems\EzPlatformContentForms\Form\Type\Content\ContentEditType;
use Ibexa\Contracts\ContentForms\Content\Form\Provider\GroupedContentFormFieldsProviderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -57,6 +58,9 @@ class ContentOnTheFlyController extends Controller
/** @var \eZ\Publish\API\Repository\PermissionResolver */
private $permissionResolver;

/** @var \Ibexa\Contracts\ContentForms\Content\Form\Provider\GroupedContentFormFieldsProviderInterface */
private $groupedContentFormFieldsProvider;

/** @var \eZ\Publish\Core\MVC\Symfony\Locale\UserLanguagePreferenceProviderInterface */
private $userLanguagePreferenceProvider;

Expand All @@ -78,6 +82,7 @@ public function __construct(
LocationService $locationService,
ContentTypeService $contentTypeService,
PermissionResolver $permissionResolver,
GroupedContentFormFieldsProviderInterface $groupedContentFormFieldsProvider,
UserLanguagePreferenceProviderInterface $userLanguagePreferenceProvider,
CreateContentOnTheFlyDispatcher $createContentActionDispatcher,
ConfigResolverInterface $configResolver,
Expand All @@ -89,6 +94,7 @@ public function __construct(
$this->languageService = $languageService;
$this->contentTypeService = $contentTypeService;
$this->permissionResolver = $permissionResolver;
$this->groupedContentFormFieldsProvider = $groupedContentFormFieldsProvider;
$this->userLanguagePreferenceProvider = $userLanguagePreferenceProvider;
$this->createContentActionDispatcher = $createContentActionDispatcher;
$this->configResolver = $configResolver;
Expand Down Expand Up @@ -213,6 +219,9 @@ public function createContentAction(
'language' => $language,
'content_type' => $contentType,
'parent_location' => $parentLocation,
'grouped_fields' => $this->groupedContentFormFieldsProvider->getGroupedFields(
$form->get('fieldsData')->all()
),
]);
}

Expand Down Expand Up @@ -354,6 +363,9 @@ private function buildEditView(
'language' => $language,
'content_type' => $contentType,
'form' => $form->createView(),
'grouped_fields' => $this->groupedContentFormFieldsProvider->getGroupedFields(
$form->get('fieldsData')->all()
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only note is here, that field grouping should be done in the form type itself, during buildView method.

]);

return $view;
Expand Down