As the title reads, I'm attempting to add a custom made module (simple contact form) into a region on my front page (this may be used other places as well, but for not just the front page). Could some one lend me their eyes/advice on how to do this correctly. The region on my page is labeled sidebar_first. I have attempted to add it via a hook_block_view() functionallity, however nothing seems to be taking.


function honey_front_page_form_menu(){
global $user;
//Main Page Call Back
$items['front_page_form'] = array(
    'page callback' =>'_honey_front_page_init',
    'access arguments' => array('access content'),
    'title' => t('Honey Contact page Form'),


function honey_front_page_form_admin_form(){

  $form['front_form'] = array(
        '#type' => 'fieldset',
        '#title' => t('Admin Menu'),

  $form['front_form']['name'] = array(
    '#type' => 'textfield',
    '#attributes' => array('placeholder' => t('name')),
    '#required' => TRUE,


  $form['front_form']['email'] = array(
    '#type' => 'textfield',
    '#attributes' => array('placeholder' => t('email')),
    '#required' => TRUE,


  $form['front_form']['phone'] = array(
    '#type' => 'textfield',
    '#attributes' => array('placeholder' => t('phone')),
    '#required' => TRUE,
    '#maxlength' => 15

    $form['front_form']['comments'] = array(
    '#type' => 'textfield',
    '#attributes' => array('placeholder' => t('comments')),
    '#required' => FALSE,


  $form['front_form']['submit'] = array(
    '#type' => 'submit',
    '#value' => 'SUBMIT NOW',
    '#field_prefix' => '<h3>',
    '#field_suffix'=> '</h3>'



function honey_front_page_form_block_view($delta = ''){
//ensures form is only called on the front page.

// if (!drupal_is_front_page()){
//     return NULL;
// }

    if($delta == '1'){
        $form = drupal_render( drupal_get_form('honey_front_page_form_admin_form'));
    $block = array(
        // 'subject' => t('Subject'),
        'content' => $form,

    return $block;


Take a look at the Drupal block APIs. You need to use hook_block_info to define a block. Then use hook_block_view to return the rendered content of the block. You will still need to include the block, ether programmatically, or by using admin/structure/block.

| improve this answer | |
  • Perfect thanks for the advice and direction. I didn't think I was needing to define the module in that manner. I was simply thinking I'd be able to piggy back the forms into a block. – KaosAkroma Oct 23 '14 at 1:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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