Error Passing Extra Parameter to Custom Form I have a simple custom form that works until I try to add a custom parameter for my module called "forms_admin".

These are the contents of my forms_admin.routing.yml

forms_admin.settings:
  path: 'admin/config/system/forms/{arg1}'
  defaults:
    _form: '\Drupal\forms_admin\Form\FormSettings'
    _title: 'Forms Settings'
  requirements:
    _permission: 'access content'


This is a relevant part of my FormSettings.php file (Currently do not have any custom Validation or Submit actions)

public function buildForm(array $form, FormStateInterface $form_state, $arg1 = NULL) {
    $form['title'] = array(
      '#type' =&gt; 'textfield',
      '#title' =&gt; t('Title'),
      '#required' =&gt; TRUE,
    );

    $form['submit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Submit'),
    );


return $form;
}


And my third file is: forms_admin.links.menu.yml

forms_admin.config:
  title: Forms
  route_name: forms_admin.settings
  parent: system.admin_config_system
  description: 'Forms settings'
  weight: 0


The moment that I add {arg1} to my forms_admin.routing.yml and , $arg1 = NULL to my FormSettings.php file, I am unable to acces the website.



I receive a white page with the error that states:


  The website encountered an unexpected error. Please try again later.


After removing arg1 from my two files and going to the Recent Log messages, this is the error I receive:


  Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("arg1") to generate a URL for route "forms_admin.settings". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 182 of /var/www/test_site/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php).




I have tried changing arg1 to other names, not making $arg1 = NULL, etc. and I receive an error every time. 

What am I missing?
The problem is that your FormSettings class is not the controller in this case. It's the controller method which is where the routing system expects $arg_1.

I think you need to define your own controller which accepts the request and passes the argument to the form. Extending the core Drupal\Core\Controller\FormController class is probably the simplest way forward.