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

Allow multiple form data tabs on parent view #315

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
17 changes: 12 additions & 5 deletions Admin/DynamicListAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,27 @@ public function __construct(ViewBuilderFactoryInterface $viewBuilderFactory, arr

public function configureViews(ViewCollection $viewCollection): void
{
$action = 'form-list';
// TODO handle multipage views

foreach ($this->config as $parent => $sections) {
luca-rath marked this conversation as resolved.
Show resolved Hide resolved
foreach ($sections as $key => $config) {
/** @var mixed[] $config */
foreach ($sections as $config) {
luca-rath marked this conversation as resolved.
Show resolved Hide resolved
if (!$viewCollection->has($parent)) {
continue;
}

$name = $parent . '.' . $action . '-key';
$action = 'form-list';
if (isset($config['action'])) {
$action = $config['action'];
}
luca-rath marked this conversation as resolved.
Show resolved Hide resolved

$name = $parent . '.' . $action;
luca-rath marked this conversation as resolved.
Show resolved Hide resolved
if (isset($config['name'])) {
$name = $config['name'];
}

if ($viewCollection->has($name)) {
throw new \RuntimeException(\sprintf('View "%s" does already exist.', $name));
}

$requestParameters = [
'type' => $config['type'],
];
Expand Down
1 change: 1 addition & 0 deletions Resources/doc/dynamic.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ sulu_form:
dynamic_lists:
sulu_page.page_edit_form: # view key e.g. "sulu_page.page_edit_form" for sulu pages or "sulu_article.edit_form" for sulu articles.
form: # unique key mostly the same as the template key or a combination between template and property key.
Copy link
Member

Choose a reason for hiding this comment

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

as reading this command I think we should just use the key as postfix for the viewbuilder, so uniqueness is defined by the yaml key.

action: form-list # the path of the view
luca-rath marked this conversation as resolved.
Show resolved Hide resolved
template: form # template key
property: form # form property name
type: page # the site type e.g. page, article, … (same as the content type type param)
Expand Down
38 changes: 4 additions & 34 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,23 @@ parameters:
path: Admin/DynamicListAdmin.php

-
message: "#^Cannot access offset 'name' on mixed\\.$#"
count: 2
path: Admin/DynamicListAdmin.php

-
message: "#^Cannot access offset 'position' on mixed\\.$#"
count: 2
path: Admin/DynamicListAdmin.php

-
message: "#^Cannot access offset 'property' on mixed\\.$#"
count: 2
path: Admin/DynamicListAdmin.php

-
message: "#^Cannot access offset 'template' on mixed\\.$#"
count: 2
path: Admin/DynamicListAdmin.php

-
message: "#^Cannot access offset 'type' on mixed\\.$#"
message: "#^Parameter \\#1 \\$name of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ViewBuilderFactoryInterface\\:\\:createListViewBuilder\\(\\) expects string, mixed given\\.$#"
count: 1
path: Admin/DynamicListAdmin.php

-
message: "#^Cannot access offset 'view' on mixed\\.$#"
count: 2
path: Admin/DynamicListAdmin.php

-
message: "#^Parameter \\#1 \\$name of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ViewBuilderFactoryInterface\\:\\:createListViewBuilder\\(\\) expects string, mixed given\\.$#"
message: "#^Parameter \\#1 \\$tabOrder of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ListViewBuilderInterface\\:\\:setTabOrder\\(\\) expects int, mixed given\\.$#"
count: 1
path: Admin/DynamicListAdmin.php

-
message: "#^Parameter \\#1 \\$tabOrder of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ListViewBuilderInterface\\:\\:setTabOrder\\(\\) expects int, mixed given\\.$#"
message: "#^Parameter \\#1 \\$viewName of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ViewCollection\\:\\:has\\(\\) expects string, mixed given\\.$#"
count: 1
path: Admin/DynamicListAdmin.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 1
count: 2
path: Admin/DynamicListAdmin.php

-
Expand Down Expand Up @@ -330,11 +305,6 @@ parameters:
count: 1
path: Controller/FormTokenController.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\Form\\\\FormError\\|Symfony\\\\Component\\\\Form\\\\FormErrorIterator\\:\\:getMessage\\(\\)\\.$#"
count: 2
path: Controller/FormWebsiteController.php

-
message: "#^Cannot call method all\\(\\) on Symfony\\\\Component\\\\Form\\\\FormInterface\\|null\\.$#"
count: 1
Expand Down