So I am recently started working on front-end development, and have started messing around with making my own custom templates for modules. I have been able to get page related templates to work, but am having a problem getting form related templates to work.
This is for Drupal 7.
I have a form, like this (Its not quite this basic, but very similar and no special fields)
function mymodule_menu() {
$items['admin/atavism/config'] = array(
'title' => 'Configuration',
'page callback' => 'drupal_get_form',
'page arguments' => array('atavism_config'),
'access arguments' => TRUE,
);
}
function atavism_config() {
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Save Configuration',
);
$form = theme('atavism_config_form', array('form',$form));
return $form;
}
function atavism_theme() {
return array(
'atavism_config_form' => array(
'template' => 'page--atavism-config-form',
'path' => drupal_get_path('module','atavism') . '/theme',
),
);
}
And then I created the page--atavism-config-form.tpl.php
. Inside of the form, I am using;
print render($form);
I am doing the same thing for pages that are just content (normal pages with just text and markup for example, and no forms), and it's working as intended, but I am also doing the same thing for a couple of different forms I have, and I am running into two problems. Either #1, the form renders in the template, but ONLY the provided $form
variables are available (so the form can't be submitted), or I get a white screen with a PHP error of 'Unsupported operand'.
It appears I may be doing something wrong with forms, but I can't figure out what. Could somebody please help me?