I want to create my custom module for making contact form using FAPI. I created 2 files one is .info
and other is .module
. But I can not understand how should I link that module with my template name page--contact-us.tpl.php
as I already activate that module from module list.I used the below code in my module_name-modul
<?php function my_module_form($form,&$form_state) { $form['name'] = array( '#type' => 'textfield', ); $form['company'] = array( '#type' => 'textfield', ); $form['phone'] = array( '#type' => 'textfield', ); $form['email'] = array( '#type' => 'textfield', ); $form['message'] = array( '#type' => 'textfield', ); return $form; }
then in template.php file I write the below code
<?php function mytheme_theme($existing, $type, $theme, $path) { $items['my_module_form'] = array( 'render element' => 'form', 'template' => 'page--contact-us', 'path' => drupal_get_path('theme', 'mytheme') . '/template', ); return $items; } ?>
and in last ,I write a single line of code in my page--contact-us.tpl.php
file to check whether a name field
is appearing or not <?php print render($form['name']); ?>
. But nothing is happening on my contact-us page?
Custom Form module
nomeer
- 99
- 1
- 10