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

Cannot copy a form when the admin locale is not defined in the webspace #364

Open
eekes opened this issue Jul 20, 2023 · 1 comment
Open
Labels

Comments

@eekes
Copy link
Contributor

eekes commented Jul 20, 2023

Q A
Bug? yes
New Feature? no
Bundle Version 2.5.2
Sulu Version 2.5.9

Actual Behavior

When trying to copy a form for a locale that's only available in the "admin" part, this line throws this error:

Call to a member function getTitle() on null

Expected Behavior

The form should be copied

Steps to Reproduce

Set this in sulu_admin.yaml:

sulu_core:
    locales:
        nl: Nederlands
        en: English
    translations:
        - nl
        - en

And this in the webspace config:

    <localizations>
        <localization language="en" default="true" />
    </localizations>

Then create a form in the only possible locale (EN) and try to copy a form with the backend locale set to "NL"

Possible Solutions

I could possibly create a merge request, but I'm not sure what you guys would prefer. Use the title of a known locale in the event, or just return an empty string if the form is not available in the admin locale.

@alexander-schranz
Copy link
Member

alexander-schranz commented Jul 20, 2023

I would go with using a title of a known locale. maybe following is enough:

        $newFormTranslation = $newForm->getTranslation($locale) ?: $newFormTranslation;

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

No branches or pull requests

2 participants