I have call my current contactform with this function in mytheme.theme.
$form = Drupal::routeMatch()->getParameter('contact_form');
I have this
object(Drupal\contact\Entity\ContactForm)#412 (23) {
["id":protected]=>
string(8) "feedback"
["label":protected]=>
string(14) "Nous contacter"
["recipients":protected]=>
array(1) {
[0]=>
string(21) "mymail@gmail.com"
}
["reply":protected]=>
string(0) ""
["weight":protected]=>
int(0)
["originalId":protected]=>
string(8) "feedback"
["pluginConfigKey":protected]=>
NULL
["status":protected]=>
bool(true)
["uuid":protected]=>
string(36) "6e997e8b-9d85-4e59-9e43-67004270fe13"
["isSyncing":"Drupal\Core\Config\Entity\ConfigEntityBase":private]=>
bool(false)
["isUninstalling":"Drupal\Core\Config\Entity\ConfigEntityBase":private]=>
bool(false)
["langcode":protected]=>
string(2) "fr"
["third_party_settings":protected]=>
array(0) {
}
["_core":protected]=>
array(0) {
}
["trustedData":protected]=>
bool(false)
["entityTypeId":protected]=>
string(12) "contact_form"
["enforceIsNew":protected]=>
NULL
["typedData":protected]=>
NULL
["cacheContexts":protected]=>
array(1) {
[0]=>
string(28) "languages:language_interface"
}
["cacheTags":protected]=>
array(0) {
}
["cacheMaxAge":protected]=>
int(-1)
["_serviceIds":protected]=>
array(0) {
}
["dependencies":protected]=>
array(0) {
}
}
But how can I rendering this ? My goal is to render the current contact form.
Edit1: I have tried this How to programmatically render a contact form in a theme in D8
But when I try this
$form = Drupal::routeMatch()->getParameter('contact_form');//get the current form called
$message = \Drupal::entityManager()
->getStorage('contact_message')
->create(array(
'contact_form' => $form->id(),
));
//$form->id() = 'feedback'
$form = Drupal::service('entity.form_builder')->getForm($message);
I have a very big array (Firefox and Chrome crash when in print them )
When I try this
$form = Drupal::routeMatch()->getParameter('contact_form');//get the current form called
ContactController::contactSitePage($form);
I have this error
PHP Fatal error: Call to a member function getStorage() on null in /var/www/drupal8/core/modules/contact/src/Controller/ContactController.php on line 83
Why I would like to do this in my .theme file ?
Because I have begin to migrate a website in drupal 6 to drupal 8 .(I have try Drupal Upgrate and they works very good ) The page of this website has been built with a little home framework. It call many others not Drupal script. With this, not Drupal Script (Ex:tagada.com/horoscope.php ) and drupal page ( tagada.com/drupalpart/node/10) works with same css and html structure file in a external folder. In Drupal6 the theme worked correctly with a global variable object with node content $node
drupal_render
? I do not know if that works or not.