By dynamate on
I was wondering what would be the best way to override the way a form looks in Drupal 7 using PHPTemplate. I have some difficulties displaying all the information on my page.
I have a page with a form and some miscellaneous information.
I have tried:
foo.module
function foo_add_form($form, &$form_state, $foo) {
...
$form['#theme'] = 'foo_add';
return $form;
}
function foo_theme($existing, $type, $theme, $path) {
return array(
'foo_add' => array(
'template' => 'foo-add',
'render element' => 'form',
),
);
}
foo-add.tpl.php
<?php
// First form
print drupal_render_children($form);
?>
<!-- Miscellaneous information -->
<div id="links">
<ul>...</ul>
<form action="#" method="post" id="second-form">
<fieldset id="i-want">
...
</fieldset>
...
</form>
</div>
At the moment the form and miscellaneous information are being displayed. However, the 2nd form (id="second-form") is being removed somehow. I can see it in the source, but when I inspect the element with chrome/firefox, I can no longer see the form element. I can see the div, ul and fieldset tags though.
Has anybody done this before?
Comments
strange feeling about forms
I looked all over myself. I have a strange feeling that you have to conform to the form api. You cannot produce a form directly in the template because the way the form api is designed into Drupal. It's like an electronic automobile motor, when it breaks down, you can't just go to any mechanic to get it fixed.
Let me know if you found a way to produce a form within a template. There is a lot of things I have to do that I can't because forms are layered away from the view in Drupal. Just like in your example, Miscellaneous forms are pretty much essential for AJAX forms updating the main form with relevant information.