title: Same form in multiple locations in Thymeleaf 3 & Spring 4
body: <p>I'd like to have my login form (for example) on multiple pages, and I want to pre-populate it with the current user's login (assuming that user is recognized via cookie). But I don't want every controller method for every possible page to have to provide a LoginForm bean for the form. I do want all the validation magic when the form is submitted, and then of course I want the result of the form to the same page the user was on when they submitted it.</p>
  
  <p>I can't quite figure out how to accomplish this right now. Is it even possible?</p>
  
  <p>EDIT:</p>
  
  <p>I've got a Thymeleaf form like this:</p>
  
  <pre><code>&lt;form action="#" data-th-action="@{/users/login}" data-th-object="${loginForm}" method="post"&gt;
      &lt;input type="text" placeholder="Email or Username" data-th-field="${loginForm.login}"&gt;
      &lt;input type="password" placeholder="Password" data-th-field="${loginForm.password}"&gt;
      &lt;button type="submit" name="login"&gt;Sign in&lt;/button&gt;
      &lt;button type="submit" name="register"&gt;Register&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>If I don’t create a <code>LoginForm</code> (my class) bean and stick it in the model under <code>loginForm</code>, then I get an exception on GET, when rendering the page.</p>