0

I'm trying to setup a custom module that provide content from an API.The API url is configurable, but as it is different for each language I must be able to translate it. I setup my module configuration as described here (see the gist below) but when I try to access the translation form from /admin/config/regional/config-translation, i get "Access denied"

What am I doing wrong ?

https://gist.github.com/julien-maitan/ffd136bc104d3dbe2ee526367ffcb44c

1 Answer 1

0

First of all,

  1. Does your custom permission configure crtib configurator is defined in a permissions.yml file ? And did you give this permission to your user ?

  2. Where is your config/install settings file ? In your case your crtib_configurator.settings.yml ? Did you miss it ?

These files are not mandatory by default in Drupal 8, but are required once we want to make your configuration translatable.


I would suggest you this 2 articles:


Update - With Review of Google Drive Files

  1. config folder should be placed in the root of your module not in src;
  2. crtib_configurator.links.task.yml use a wrong route_name crtib_configurator.api_settings_translate, it should be crtib_configurator.api_settings.

Apply those 2 changes & clear your cache, you will then be able to use the translations form properly.

I think the main & initial error was the config folder location.

Directory structure:

. +-- crtib_configurator | +-- config | | +-- install | | | +-- crtib_configurator.api.yml | | +-- schema | | | +-- crtib_configurator.schema.yml | +-- src | | +-- Form | | | +-- SettingsForm.php | +-- crtib_configurator.config_translation.yml | +-- crtib_configurator.info.yml | +-- crtib_configurator.links.menu.yml | +-- crtib_configurator.links.task.yml | +-- crtib_configurator.permissions.yml | +-- crtib_configurator.routing.yml 

Content of crtib_configurator.links.task.yml:

crtib_configurator.api_settings: route_name: crtib_configurator.api_settings title: 'CRTIB configurator settings' base_route: crtib_configurator.api_settings 
Sign up to request clarification or add additional context in comments.

6 Comments

custom permissions are defined in crtib_configurator.permissions.yml. user was granted permissions. even the super adminsitrator get an access denied. settings file is in src/config/install/crtib_configurator.settings.yml, schema is in src/config/schema/crtib_configurator.schema.yml, other files are in the module root directory. I added crtib_configurator.links.task.yml file has suggested in the first article I still get access denied
Could you please add your code from \Drupal\crtib_configurator\Form\SettingsForm & crtib_configurator.permissions.yml here or in your gist.
Plus, could you upload your module crtib_configurator as a zip somehwere ? So I would be able to install it & saw the error, it's maybe a typo in the folders/files structure.
I tried to changes some names since last Gist but without success. Here is the last version of my module : drive.google.com/open?id=1blRbUOZq0gF1Aj7VtTNgVcvIyKgS55le
I updated my answer with a final contribution to fix your issue. I test it on my sandbox environment & it works properly now. I think the main & initial error was the config folder location, see me complete answer.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.