Here's my dilemma, I built a custom form-based module that allows a user to vote on a future conference location but I'm having a issue printing or rendering my form fields to have them display in my custom block template.
eventvoting.module
<?php
/**
* @file
* Title : Drupal 7 Event Voting form in a block pattern with template file
* Author : Kenyon M. Johnston
*
* Web application form that allows site visitors to vote on what city they
* would like to see host their favorite event next year.
*/
/**
* Implmentation of hook_permission()
*/
function eventvoting_permission(){
return array (
'Administer event voting form' => array(
'title' => t('Administer event voting form'),
'description' => t('Allows users to implement custom css class for the Event Voting Form module'),
)
);
}
/**
* Implements hook_block_info().
*/
function eventvoting_block_info() {
$block['eventvoting_block'] = array(
'info' => t('Event Voting Form Block'),
'cache' => DRUPAL_CACHE_PER_ROLE,
);
return $block;
}
/**
* Implementation of hook_block_view()
*/
function eventvoting_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'eventvoting':
$block['subject'] = t('');
$block['content'] = array(
'#theme' => 'eventvoting',
'#vote_event_name' => variable_get('event_name'),
'#vote_city' => variable_get('city'),
'#vote_name' => variable_get('name'),
'#vote_email' => variable_get('email'),
'#vote_submit' => variable_get('submit'),
);
break;
}
return $block;
}
/*
* Implements hook_theme
*/
function eventvoting_theme(){
return array (
'eventvoting' => array (
'arguments' => array(
'vote_event_name' => NULL,
'vote_city' => NULL,
'vote_name' => NULL,
'vote_email' => NULL,
'vote_submit' => NULL,
),
// Use a template file called eventtheme.tpl.php
'template' => 'theme/eventtheme',
),
);
}
/**
* Implements hook_menu().
*/
function eventvoting_menu() {
$items['event-voting-form'] = array(
'title' => 'Event Voting Form',
'page callback' => 'drupal_get_form',
'page arguments' => array('eventvoting_form'),
// Use the default/standard site configuration permission.
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
/**
* Creates/returns a form to configure the block's variables.
*
* @param array $form
* @param array $form_state
* @return array
*/
function eventvoting_form($form, &$form_state) {
$form['event_name'] = array(
'#title' => t('Select an event:'),
'#type' => 'textfield',
'#default_value' => variable_get('event_name'),
'#required' => TRUE,
'#weight' => 0,
);
$form['city'] = array(
'#title' => t('Vote for a city:'),
'#type' => 'textfield',
'#default_value' => variable_get('city'),
'#required' => TRUE,
'#weight' => 0,
);
$form['name'] = array(
'#title' => t('Your name:'),
'#type' => 'textfield',
'#default_value' => variable_get('name'),
'#required' => TRUE,
'#weight' => 0,
);
$form['email'] = array(
'#title' => t('Your email:'),
'#type' => 'textfield',
'#default_value' => variable_get('email'),
'#required' => TRUE,
'#weight' => 0,
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Vote'),
);
return $form;
}
**<h2><strong>eventheme.tpl.php (inside the "theme" directory)</strong></h2>**
<?php
/*
* File : eventtheme.tpl.php
* Title : Drupal 7 Event Voting Location form in a block pattern with template file
* Author : Kenyon M. Johnston
*
*/
?>
<div class="event-voting-form">
<form>
<h2>Vote for Next Year's Event</h2>
<div id="vote_event_name">
<?php print $vote_event_name; ?>
</div>
<div id="data-fieldset">
<div id="vote_city">
<?php print $vote_city ?>
</div>
<div id="vote_name">
<?php print $name ?>
</div>
<div id="vote_email">
<?php print $email ?>
</div>
<div id="vote_submit">
<?php print $submit ?>
</div>
</div>
<?php print drupal_render_children($form); ?>
</form>
</div>
My goal is to render my fields of choice. The theme renders in the block but not the fields,
This has been racking my brain for a few hours now, any help and assistance would be GREATLY appreciated.