Register form is not sticky when used in dropdown menu

I added the registration form as a dropdown form next to the Log In button at the top. Everything works fine unless registration fails and then the form does not retain its values.

The sticky form functions are still be called as the views and actions are the same as before.

I'm using the code below in the view that places the register dropdown button on the page:

$form = elgg_view_form('register', array('action' => "{$login_url}action/register"), array('returntoreferer' => TRUE));

<div id="register-dropdown">

<?php       
                echo elgg_view('output/url', array(
                        'href' => 'register#register-dropdown-box',
                        'rel' => 'popup',
                        'class' => 'elgg-button elgg-button-dropdown',
                        'text' => elgg_echo('register'),
                ));
                echo elgg_view_module('dropdown', '', $form, array('id' => 'register-dropdown-box'));
        ?>


</div>

 

Am I missing something?