Skip to main content
9 events
when toggle format what by license comment
Aug 24, 2020 at 18:04 comment added hotwebmatter @sonfd Thank you, that makes sense. This method works for me in my config form; it just isn't available in my custom service class because that class does not inherit the methods from ConfigFormBase. I'll change it back. EDIT: Never mind, I see you beat me to it. Thanks again!
Aug 24, 2020 at 16:58 comment added sonfd The docs were actually correct to begin with. As I tried to explain in the comment, ConfigFormBase has a config() method.
Aug 24, 2020 at 15:54 comment added hotwebmatter @leymannx I fixed the line in the docs: drupal.org/node/2206607/revisions/view/11783167/12036988
Aug 24, 2020 at 13:10 comment added sonfd Also note that the ConfigFormBase class uses the ConfigFormBaseTrait which defines a method config() which is not the same as simply naming your injected config factory service $config. You can see that method is a shortcut to the above, it's similar to calling \Drupal::config().
Aug 24, 2020 at 12:52 comment added norman.lol @hotwebmatter – Which lines in the docs exactly are you referring to? We should update the docs then. But note, that the ConfigFormBase already comes with the config factory pre-injected you then in a custom service class need to inject yourself. See git.drupalcode.org/project/drupal/-/blob/8.9.3/core/lib/Drupal/…
Aug 24, 2020 at 2:59 comment added hotwebmatter By the way, the bug in my code came straight from Drupal community documentation: drupal.org/docs/drupal-apis/configuration-api/…
Aug 23, 2020 at 23:01 comment added hotwebmatter Perfect answer! You even ended on exactly the line where I forgot the ->get after $this->config. Thank you.
Aug 23, 2020 at 22:57 vote accept hotwebmatter
Aug 23, 2020 at 22:40 history answered sonfd CC BY-SA 4.0