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

Creating multiple translations using shadowStrategy #195

Open
mcube27 opened this issue Dec 23, 2022 · 1 comment
Open

Creating multiple translations using shadowStrategy #195

mcube27 opened this issue Dec 23, 2022 · 1 comment

Comments

@mcube27
Copy link

mcube27 commented Dec 23, 2022

Hi,

I have an article with translated name and description. I use the shadow strategy.

If I want to create multiple translations for an article, I need to pass this:

$article = ArticleFactory::make()
            ->withArticlesTranslations(
                [
                    [
                        'id' => 1,
                        'locale' => 'fr',
                        'name' => 'Français',
                        'description' => 'Une phrase',
                    ],
                    [
                        'id' => 1,
                        'locale' => 'en',
                        'name' => 'English',
                        'description' => 'A sentence',
                    ],
                ]
            )
            ->persist();

If I do this, the translations do persist in the database and the id is corrected by cakephp to the article id.

I I omit the 'id', then the translation do not get persisted.

It does not feel intuitive nor very nice to add an id that doesn't mean anything.

I use Cakephp 4.4

@pabloelcolombiano
Copy link
Collaborator

Hi,

normally you should not need to add this id. How is the association between Articles and ArticlesTranslationsdefined in the ArticlesTable and in the ArticlesTranslationsTable?

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

2 participants