How to pass a parameter into a form upon creating? I have a form, which contains an additional field. And I want to initiate the field via the form constructor.

class ServicesForm extends FormBase {

    private $service_type;

    public function __constructor($_service_type){
        $this-&gt;service_type = $_service_type;
    }


The form is created in a controller.

class ServicesController extends ControllerBase {

    public function getServices($service_type){
        $data['form'] = \Drupal::formBuilder()-&gt;getForm('\Drupal\palom_services\Form\ServicesForm');

        return $data;
    }


Could you clarify me, how to pass the parameter $service_type to the form inside the controller method ? 

Maybe, should I do it without FormBuilder and getForm ?
Just add it to your form's buildForm method signature:

public function buildForm(array $form, FormStateInterface $form_state, $arg = NULL) {
  // Use $arg
}


Then literally pass it to the form builder's getForm method:

$data['form'] = \Drupal::formBuilder()-&gt;getForm('\Drupal\palom_services\Form\ServicesForm', $service_type);