TransWikia.com

Ajax Form Not Working in some Some Regions

Drupal Answers Asked by Sandesh Yadav on November 23, 2021

I created an ajax based contact form in my module.Then I made a block view for the form. I tried putting that block to several regions. When I put the block to ‘Sidebar Second’ the form works as desired.But when I put the same block to ‘contact’ Region (custom region) , the form’s ajax part does not work .

This is the code I used to print the block .

$contact = render(block_get_blocks_by_region('contact'));
print  $contact; 

When I inspect the element the form-id is ‘myform’ as given by me . Still the ajax part is not working .

2 Answers

There are many reasons which impact Form Ajax, would suggest check once below points

  1. HTML structure after rendering from Sidebar Second
  2. Is there any Javascript error in your page?
  3. Refer https://www.drupal.org/forum/support/module-development-and-code-questions/2019-06-19/why-is-my-ajax-not-working

Answered by Madhav Vyas on November 23, 2021

I got the solution for this . Just want to tell the answer for anyone who might come across this problem. The problem was :

I was printing it in html.tpl.php.

The solution is

print it on either page.tpl.php or page--xxxx.tpl.php and print it as

<?php 
     print render($page['contact']);
 ?>

Answered by Sandesh Yadav on November 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP