Form theming not working Please could someone advise what is wrong with the following? When the page loads it downloads an unknown file type. The form is displayed but not with the template/theming.

The form...

function test_form($form, &amp;$form_submit) {
    $form['message'] = array(
            '#type' =&gt; 'textarea',
            '#title' =&gt; t('Message'),
            '#required' =&gt; TRUE,
    );
    $form['submit'] = array(
            '#type' =&gt; 'submit',
            '#value' =&gt; t('Send')
    );

    // Get the path to the module
    $path = drupal_get_path('module', 'test');

    // Attach the CSS and JS to the form
    $form['#attached'] = array
    (
            'css' =&gt; array
            (
                    'type' =&gt; 'file',
                    'data' =&gt; $path . '/css/test.css',
            ),
            'js' =&gt; array
            (
                    'type' =&gt; 'file',
                    'data' =&gt; $path . '/js/test.js',
            ),
    );

    $form['#theme'] = 'test_form';
    return $form;
}


The theme...

function test_theme($existing, $type, $theme, $path) {
    return array(
            'test_form' =&gt; array(
        //'arguments' =&gt; array('form' =&gt; null),
        'path' =&gt; drupal_get_path('module', 'test') . '/templates',
        'template' =&gt; 'test',
        'render element' =&gt; 'form',
            ),
    );
}


The directory...


test 
test/css/test.css 
test/js/test.js 
test/templates/test.tpl.php
test/test.info test/test.module
It sounds like there is just a problem with the loading of the attached files in your $form['#attached'] setting. Are you getting 404 errors from your debugger for the js and css files or is it not trying to load them?

You should try rewriting your form settings with the type as a settings array (if you need it) according to the API documentation

$form['#attached'] = array
(
        'css' =&gt; array
        (
                $path .'css/test.css' =&gt; array('type' =&gt; 'file',),
        ),
        'js' =&gt; array
        (
                $path .'js/test.js' =&gt; array('type' =&gt; 'file',),
        ),
);


or maybe more simply as:

$form['#attached']['css'] = array(
  drupal_get_path('module', 'test') . 'css/test.css',
);

$form['#attached']['js'] = array(
  drupal_get_path('module', 'test') . 'js/test.js',
);