1

In Drupal 8, I created a form Class. I can access to this form with the route defined in the yml file.

I want load the form page without any theme/elements Drupal, just show the form (with a minimal css for align the form to the center of the page). Is there a simple way for do that ?

1 Answer 1

1

I know it's possible to have a Controller action return raw HTML, by returning a Symfony\Component\HttpFoundation\Response object with the html string as an argument. IE

namespace Drupal\my_module\MyController;

use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\Response;

class MyController extends ControllerBase {
  public function content() {
    $markup = '<h1>Behold my markup!</h1>';
    return new Response($markup);
  }
}

If that's what you are going for, you could hard code the form instead of using the drupal form api. It does mean abandoning the functionality of the form api as well though - you are basically creating a route to a plain html page.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.