I have figured this out.
Step 1):
Find the ID of your form.
To do this, view the source of the form and search for "form" keep on searching until you see a field like this:
<form enctype="multipart/form-data" action="SOME_URL_HERE" method="post" id="commerce-bpc-create-bulk-form" accept-charset="UTF-8"><div>
The id you want is in the id=""
string
You need to tell Drupal where to find your tpl.php file.
In template.php add the following:
function YOURTHEME_theme($existing, $type, $theme, $path) {
return array(
'INSERT_ID_HERE' => array(
'arguments' => array('form' => NULL),
'template' => 'templates/add/node--add--TEMPLATE_NAME',
'render element' => 'form',
),
);
}
So if you were themeing a Drupal Commerce Bulk Product Creation form, your code would look like this:
function YOURTHEME_theme($existing, $type, $theme, $path) {
return array(
'commerce_bpc_create_bulk_form' => array(
'arguments' => array('form' => NULL),
'template' => 'templates/add/node--add--bpc',
'render element' => 'form',
),
);
}
3) Create a tpl.php template file and save it in the appropriate directory.
In our example, the file is called node--add--bpc.tpl.php
and is saved in templates/add
4) In your tpl.php file, insert variables for the fields on the form. Here is a list of the most common fields:
<?php print drupal_render($form['product']['sku_fragment']); ?>
<?php print drupal_render($form['product']['title_fragment']); ?>
<?php print drupal_render($form['product']['commerce_price']); ?>
<?php print drupal_render($form['submit']); ?>
<?php print drupal_render($form['static_values']['field_YOUR_CUSTOM_FIELD']); ?>
5) At the end of the tpl.php file, put the following code:
<?php print drupal_render_children($form) ?>
It's very important you put this code, or you will get errors when trying to upload images.
6) The code in step 5, might print out fields you do not want. So you to have unset these fields. Here is a list of the most common fields to unset.
<?php unset ($form['product']); ?>
<?php unset ($form['combinations']); ?>
<?php unset ($form['title']); ?>
<?php unset ($form['static_values']); ?>
<?php unset ($form['description']); ?>
You put all this code on a line before:
<?php print drupal_render_children($form) ?>
7) If you find that any of the steps don't work, be sure to flush your cache. You can do this at: yousite.com/admin/config/development/performance