resolve_form_state_argument_type config is not being used

Created on 6 March 2024, 8 months ago
Updated 20 March 2024, 8 months ago

Problem/Motivation

This module provides a resolve_form_state_argument_type boolean config value.
When set to TRUE we enable our ModelValueResolver to also resolve FormStateInterface typehinted parameters in controller methods.

It allows developers to use $formState instead of $form_state.
As long as they typehinted correctly, we'll resolve it.

BUT it appears we reference wmmodel.settings instead of entity_model.settings.
So the config isn't being found.

Our tests pass because we also reference wmmodel in our tests.

Steps to reproduce

Set the resolve_form_state_argument_type config value to TRUE and visit a form.

my_module.config.mails:
  path: '/admin/config/mails'
  defaults:
    _form: '\Drupal\my_module\Form\Admin\Mail\MailSettingsForm'
    _title: 'Mail settings'
  requirements:
    _permission: 'access content overview'
class MailSettingsForm extends ConfigFormBase
{
    public function getFormId(): string
    {
        return 'my_module.config.mails';
    }

    public function buildForm(array $form, FormStateInterface $formState)
    {
        // We never get to this point
    }

When visiting /admin/config/mails you get the following error:

RuntimeException: Controller "Drupal\my_module\Form\Admin\Mail\MailSettingsForm::buildForm" requires that you provide a value for the "$formState" argument.).

Drupal\Core\Controller\FormController->getContentResult(Object, Object)

Proposed resolution

Rename all occurrences of wmmodel.settings to entity_model.settings

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇧🇪Belgium Robin.Houtevelts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024