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

Submit Bug at admin panel preview #367

Open
GameFixxer opened this issue Aug 16, 2023 · 2 comments
Open

Submit Bug at admin panel preview #367

GameFixxer opened this issue Aug 16, 2023 · 2 comments

Comments

@GameFixxer
Copy link

GameFixxer commented Aug 16, 2023

Q A
Bug? yes
New Feature? no

| Bundle Version | "sulu/form-bundle": "^2.5",
| Sulu Version | "sulu/sulu": "~2.5.10",
| Browser Version | Google Chrome Version 114.0.5735.198 (Official Build) (64-bit)

Actual Behavior

Submitting the Form results in an error:
Sulu\Bundle\FormBundle\Form\Builder::createForm(): Argument #6 ($webspaceKey) must be of type string, null given, called in /home/reneberndt/sulutest/theatertotal/vendor/sulu/form-bundle/Form/Builder.php on line 182

Expected Behavior

I would either expect it to work, or the submit functionality to be disabled.

Steps to Reproduce

With the given versions, create a Form and load it into a page, then on the admin panel preview try to fill in the form and submit it.

Possible Solutions

The issue is called by the initial value of the variable $webspaceKey being null, while the return type is a string.
Since in the preview, no webspace key is sent on the submission of the form the null value is returned.
(Data available at submit - reproducible by placing dump($request->get('_sulu'));die; at Sulu\Bundle\FormBundle\Form\Builder line 277 after filling in the form fields and before submitting)

[Builder.php](http://localhost:8000/admin/_profiler/open?file=vendor/sulu/form-bundle/Form/Builder.php&line=277#line277) on line 277: [Sulu\Component\Webspace\Analyzer\Attributes\RequestAttributes](http://localhost:8000/admin/_profiler/open?file=vendor/sulu/sulu/src/Sulu/Component/Webspace/Analyzer/Attributes/RequestAttributes.php&line=17#line17) {#2053 ▼ -attributes: array:4 [▼ "locale" => "de" "localization" => [Sulu\Component\Localization\Localization](http://localhost:8000/admin/_profiler/open?file=vendor/sulu/sulu/src/Sulu/Component/Localization/Localization.php&line=21#line21) {#2051 ▶} "scheme" => "http" "requestUri" => "/admin/preview/render?webspaceKey=example&provider=pages&id=5a08f518-97a8-4b01-b7b1-a11eca0ae116&locale=de&token=fa90c92e0874388520c9579c630326e7&targetGroupId= ▶" ] }

If the initial value of $webspaceKey at Sulu\Bundle\FormBundle\Form\Builder line 276 is set to an empty string you can effectively eliminate the error.

If wanted I can create a pull request for this.

@alexander-schranz
Copy link
Member

I think we should disable the submit listener for previews here:

+if ($request->attribute->get('preview') === true) {
+    return;
+}

@DawidFerchow
Copy link

Small change:

-if ($request->attribute->get('preview') === true) {
+if ($request->attributes->get('preview') === true) {

Proper code:

+if ($request->attributes->get('preview') === true) {
+    return;
+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants