Drupal 8 - FormBase buildForm parameter names

Submitted by superadmin on Fri, 12/25/2015 - 19:02

When creating configuration forms by extending FormBase, your buildForm method first two parameters must be named, $form and $form_state respectively. Anything else will result in the following runtime error:

::buildForm()" requires that you provide a value for the "$state" argument (because there is no default value or because there is a non optional argument after this one)

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.