Uniform Form Submission succeeds, but leads to panel login

I’m working on a couple uniform contact forms. I’ve got both of them working:

  • The validation works and prevents the form from being sent if there are errors
  • When there are no errors, the forms both send the emails with no problem

The problem, however, is that instead of refreshing the form page with a success message, the submission process links to the panel login page. I cannot for the life of me figure out why.

The simpler contact form is almost exactly copypasted from the documentation basic example.

The controller:

use Uniform\Form;

return function ($site, $pages, $page)
    $form = new Form([
        'email' => [
            'rules' => ['required', 'email'],
            'message' => 'Please enter a valid email address',
        'name' => [],
        'message' => [
            'rules' => ['required'],
            'message' => 'Please enter a message',

    if (r::is('POST')) {
            'to' => '[VALID EMAIL]',
            'from' => '[VALID EMAIL]',
            'subject' => 'New message from {name}',

    return compact('form');

The relevant portion of the template:
<div class="six columns offset-by-three">
<?php if ($form->success()): ?>
Thank you for your message. We will get back to you soon!
<?php else: ?>
<?php snippet('uniform/errors', ['form' => $form]) ?>
<?php endif; ?>

<form action="<?php echo $page->url() ?>" method="POST" class="six columns offset-by-three">
    <input<?php if ($form->error('email')): ?> class="error"<?php endif; ?> name="email" type="email" value="<?php echo $form->old('email') ?>">

    <input<?php if ($form->error('name')): ?> class="error"<?php endif; ?> name="name" type="text" value="<?php echo $form->old('name') ?>">

    <textarea<?php if ($form->error('message')): ?> class="error"<?php endif; ?> name="message"><?php echo $form->old('message') ?></textarea>

    <?php echo csrf_field() ?>
    <?php echo honeypot_field() ?>
    <input type="submit" value="Submit">

Any thoughts on what could be causing this problem?

That seems strange. What happens in your network tab after the form is submitted?

Still not sure why that was happening. Nothing jumped out at me from the network tab. I ended up solving the problem by adding the following to the POST action:

  if ($form->success()) {