I am trying to theme a custom using a template file but unfortunately I am not getting it by using the below method. listing.module
function listing_menu() {
$items['ad-listing'] = array(
'page callback' => 'adlist_template',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
function listing_form($form, &$form_state) {
$form['title'] = array(
'#type' => 'textfield',
'#attributes' => array('placeholder' => t('Title')),
);
$form['category'] = array(
'#type' => 'select',
'#options' => array(
'default' => '- Category -',
'Car' => 'Car',
'Van' => 'Van',
),
);
return $form
}
function listing_theme($existing, $type, $theme, $path){
return array(
'listing_form' => array(
'render element' => 'form',
'template' => 'adlisting',
'path' => drupal_get_path('module', 'listing') . '/form',
)
);
}
function adlist_template(){
return theme('listing_form');
}
listing/form/adlisting.tpl.php
<div class="row">
<div class="small-12 medium-12 large-8">
<div class="row">
<div class="small-12 columns">
<h5 class="">Contact Information</h5>
</div>
</div>
<div class="row">
<div class="small-12 large-6 medium-6 columns">
<?php print render($form['title']); ?>
</div>
</div>
<div class="row">
<div class="small-12 medium-6 large-6 columns">
<?php print render($form['category']); ?>
</div>
<div class="row">
<div class="small-12 medium-12 large-8 large-offset-2 columns">
<?php print render($form['ad_submit']); ?>
</div>
</div>
I tried to follow this thread How to a use a template file to theme a form? but did not help me, neither other solutions
listing_form()
to something likelisting_myform()
and flush your caches. I'm assuming your module islisting
so by naming your functionlisting_form
you are actually implementinghook_form
which I'm pretty sure you do not want to do.hook_form
. Why not?hook_form
is a node API hook (if I'm wrong feel free to enlighten me). This function above is a theme function. I honestly don't know if it would even be problematic - since obviouslyblah_form
is a popular naming convention - just trying to eliminate possible gotchas.