How can I adjust the position of a cancel button added with hook_form_alter()? Based on this answer, I added a cancel button to my user picture upload form like this:

  $types = array(
    'profile_picture',
  );

  foreach($types as $type) {
    if($type.'_node_form' == $form_id) {
      if(arg(1) == 'add') {
        // If adding node link to node/add screen
        $link = l(t('Cancel'), 'account/manage-pictures', array('attributes' =&gt; array('class' =&gt; array('form-submit','cancel'), 'id' =&gt; 'edit-cancel')));
      }
      elseif(arg(2) == 'edit') {
        // If editing node, link to node view screen
        $link = l(t('Cancel'), 'node/'.arg(1), array('attributes' =&gt; array('class' =&gt; 'form-submit, cancel', 'id' =&gt; 'edit-cancel')));
      }
      $form['cancel'] = array(
        '#type' =&gt; 'markup',
        '#markup' =&gt; $link,
        '#weight' =&gt; 0,
      );
    }
  }


However, this causes the red cancel button to be placed at the top of the form instead of the bottom of the form next to the purple save button as shown in the screenshot below.



When I examined the CSS in Firebug, I saw that the save button is under this div: &lt;div id="edit-actions" class="form-actions form-wrapper"&gt;, while the cancel button is not.  Is there a way to place the cancel button under the same div as the save button?
Use the following code.
$form['actions']['cancel'] = array(
 '#type' =&gt; 'markup',
 '#markup' =&gt; $link,
);

If it doesn't work, check with print_r() where the submission buttons are added in the form array. Usually, it's $form['actions'], but sometimes can be a different array index.