Problem/Motivation
i can't save a cloned page with automatic url alias
MSG: The alias /xyz is already used in this language
Steps to reproduce
- create a page with Auto-Path (Configure URL alias pattern.)
- clone and save the page
i can't save a cloned page with automatic url alias
MSG: The alias /xyz is already used in this language
- create a page with Auto-Path (Configure URL alias pattern.)
- clone and save the page
Comments
Comment #2
smustgrave commentedI just used the module and didn't run into this issue?
Comment #3
Sheenam khunger commentedI can also reproduce this issue. But in my case, it is only happening when url-alias pattern is like this: /staticword/node-title/
When the url-alias pattern is :/node-title then it is working fine.
Comment #4
neslee canil pintoThis seems to be a content releated issue, not able to reproduce but with #3 able to reproduce
Comment #5
duaelfrI also have this issue on one of my projects.
After xdebugging this, I figured out that the issue happens in
\Drupal\path\Plugin\Field\FieldWidget\PathWidget::validateFormElement()where Drupal checks that the given alias doesn't already exists for another source but the same language.During the usual process, either the alias is empty (new node) or the alias matches the source (node edit).
In our case, the alias is set to the cloned one by
\Drupal\quick_node_clone\Entity\QuickNodeCloneEntityFormBuilder::getForm()but the source is empty so it doesn't match.I can see two ways of solving this:
we callthis is not working because it needs a saved entity\Drupal\pathauto\PathautoGenerator::updateEntityAlias()to generate a new alias before building the formIdeally, we should unset the path alias only if the pathauto checkbox is checked but we don't know that before building the form unless we look into the Request which seem really dirty.
FIY the following hook implementation fixes the issues but it's not really clean either:
Does someone here with a big brain have an idea to fix this issue?