Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

can anyone guide me , I'm continuously facing this error , webform custom module Drupal 8

InvalidArgumentException: The form argument sun_webforms_usage_settings_page_form is not a valid form. in DrupalCoreFormFormBuilder->getFormId() (line 197 of F:wampwww eo9webcorelibDrupalCoreFormFormBuilder.php).

function neo_webforms_usage_settings_page_form($form, DrupalCoreFormFormStateInterface $form_state)
     {
         $form = array();
         $form['neo_webforms_usage_inactivity_time'] = array(
        '#title' => t('Inactivity Time (seconds)'),
        '#type' => 'textfield',
        '#default_value' => Drupal::state()->get('neo_webforms_usage_inactivity_time', 86400),
      );
            $form['neo_webforms_usage_alert_email'] = array(
        '#title' => t('Alert receiver email (one per line).'),
        '#type' => 'textarea',
        '#default_value' => Drupal::state()->get('neo_webforms_usage_alert_email', ""),
      );
    
    
      return system_settings_form($form);
    }

and Controller

public function neo_webforms_usage_settings_page() {
    $header = [
      '#type' => 'markup',
      '#markup' => t('<h4>Webform Usage Settings</h4>'),
    ];
    $form = Drupal::formBuilder()->getForm('neo_webforms_usage_settings_page_form');

    $page = [
      'header' => $header,
      'form' => $form,
    ];

    return $page;
  }
}

Please anyone help me with that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
224 views
Welcome To Ask or Share your Answers For Others

1 Answer

As per the official documentation of the FormBuilder getForm function, the parameter of getForm should be the Class/Instance name of the Form.

Parameters DrupalCoreFormFormInterface|string $form_arg: The value must be one of the following: The name of a class that implements DrupalCoreFormFormInterface. An instance of a class that implements DrupalCoreFormFormInterface.

Try passing something like this:

$form = Drupal::formBuilder()->getForm('Drupalmodule_nameFormFormClassName');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...