Generating  with the form API I  have a heavily themed form to integrate, whose structure is shown below. I am just about there for the most part except for the submit. 

 &lt;form action="#"&gt;
   &lt;fieldset&gt;
     &lt;legend&gt;Authentification&lt;/legend&gt;
       &lt;label for="email"&gt;Courriel*&lt;/label&gt;
       &lt;input type="text" name="email" id="email"&gt;
       &lt;label for="password"&gt;Mot de passe*&lt;/label&gt;
       &lt;input type="password" name="password" id="password" class="last"&gt;
       &lt;a href="#" title="Mot de passe oublié?" class="clearfix"&gt;Forgot password?&lt;/a&gt;
       &lt;button type="submit" class="clearfix"&gt;&lt;span&gt;Login&lt;/span&gt;&lt;/button&gt;
   &lt;/fieldset&gt;
 &lt;/form&gt;


I have tried many different combinations, turns out button_type has no effect on core. So I used this hack, hoping it would fix my issue. Alas, it only changes the 'type' attribute (obviously), and not the element itself. The button type can hold other elements, in this case the span is needed to hold a background image, it needs to be in a span to stretch as the text in the button is dynamic.

Does anyone have a clue as to how I can generate the following line of markup using the form API?

&lt;button type="submit" class="clearfix"&gt;&lt;span&gt;Login&lt;/span&gt;&lt;/button&gt;
As an addition, just in case someone runs into the same trouble as I did - when using the #markup or #prefix/#suffix trick on a form's actions group, the submit callback function won't be called at all, unless a submit type element is present. My workaround was like this:

$form['actions']['submit'] = array
(
    '#type' =&gt; 'submit',
    '#value' =&gt; '',
    '#attributes' =&gt; array( 'style' =&gt; array( 'display: none' )), // hide the input field
    '#submit' =&gt; array( 'my_callback_for_the_form_submit' ),
    '#prefix' =&gt; '&lt;button type="submit" class="btn btn-primary"&gt;Add &lt;i class="fa fa-plus-square-o"&gt;',
    '#suffix' =&gt; '&lt;/i&gt;&lt;/button&gt;',
);


That way you can use custom HTML for submit action groups.