Provide an easier mechanism for using drupal_get_form() directly

Created on 15 October 2013, about 11 years ago
Updated 12 September 2023, over 1 year ago

Updated: Comment #N

Problem/Motivation

As we convert forms to use FormInterface, we come across cases where the form is used not as the route controller directly, and drupal_get_form() must be used.

We end up with code like this:

drupal_get_form(new SearchBlockForm());
drupal_get_form(ConfirmDeleteMultiple::create(\Drupal::getContainer()));

Proposed resolution

Make drupal_get_form() smart enough to take a class name, and instantiate it. Follow the same code flow as HtmlFormController (the class that process _form controllers):

drupal_get_form('Drupal\comment\Form\ConfirmDeleteMultiple');
drupal_get_form('Drupal\search\Form\SearchBlockForm');

Remaining tasks

N/A

User interface changes

N/A

API changes

API addition: Allow class names to be passed to drupal_get_form().

Related Issues

πŸ“Œ Task
Status

Fixed

Version

8.0 ⚰️

Component
FormΒ  β†’

Last updated 2 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024