Provide an easier mechanism for using drupal_get_form() directly

Created on 15 October 2013, over 10 years ago
Updated 12 September 2023, 9 months 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 about 3 hours 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.69.0 2024