Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The contact module currently lets us only use a separate page to display the contact forms. In my use case this is not suited since I want to display a node on the same page.
So I tried to create the block and get the from like this:
<?php
$message = \Drupal::entityManager()->getStorage('contact_message')
->create(array(
'category' => 'feedback',
));
$form = \Drupal\contact\Controller\ContactController::contactSitePage();
?>
But this throws an error:
Fatal error: Call to undefined method Drupal\attribute_project\Plugin\Block\ContactFormBlock::currentUser()
How could this be accomplished by code?
Proposed resolution
Provide blocks for contact categories.
Remaining tasks
- Provide blocks for contact categories
User interface changes
Maybe provide checkboxes to enable a block for contact categories?
API changes
Make it easier to get the forms?
Comments
Comment #1
Lukas von BlarerComment #2
Lukas von BlarerComment #3
Lukas von BlarerComment #4
Hydra CreditAttribution: Hydra commentedYou need to get the Form form the entity form builder
Not sure if there will be a solution in Core for that.
A nice place could be in contrib like https://www.drupal.org/project/contact_form_blocks
Comment #5
Lukas von BlarerOk, I will try this.
Makes sense to provide this as a contrib module. Should we mark this as wont fix?
Comment #6
larowlanLets leave this as a feature request
Comment #7
andypostDuplicate of #1997692: Create contact form block