Uniform does't work on homepage

I use uniform a lot of time with the old version 2.3.0.
I create the controllers contact.php and home.php and they are equal:

<?php

return function($site, $pages, $page) {

   $form = uniform(
'contact-form',
array(
    'required' => array(
        'name'  => '',
        '_from' => 'email'
    ),
    'actions' => array(
        array(
            '_action' => 'email',
            'to'      => 'me@example.com',
            'subject' => 'Contact form',
            'sender'  => 'contact-form@example.com'
        )
    )
)
);

   return compact('form');
};

I use the same code in the template contact.php and home.php

<form action="<?php echo $page->url()?>#form" method="post">

    <label for="name" class="required">Name</label>
    <input<?php e($form->hasError('name'), ' class="erroneous"')?> type="text" name="name" id="name" value="<?php $form->echoValue('name') ?>" required/>

    <label for="email" class="required">E-Mail</label>
    <input<?php e($form->hasError('_from'), ' class="erroneous"')?> type="email" name="_from" id="email" value="<?php $form->echoValue('_from') ?>" required/>

    <label for="message">Message</label>
    <textarea name="message" id="message"><?php $form->echoValue('message') ?></textarea>

    <label class="uniform__potty" for="website">Please leave this field blank</label>
    <input type="text" name="website" id="website" class="uniform__potty" />

    <a name="form"></a>
<?php if ($form->hasMessage()): ?>
    <div class="message <?php e($form->successful(), 'success' , 'error')?>">
        <?php $form->echoMessage() ?>
    </div>
<?php endif; ?>

    <button type="submit" name="_submit" value="<?php echo $form->token() ?>"<?php e($form->successful(), ' disabled')?>>Submit</button>

</form>

But in the contact page works and in the homepage doesn’t.
The languages files are ok (it, en) and I set the uniform language in config.php.

What is the problem? I’m going crazy…

I try to use the new 3.0.1 but is too complicated for me, I can’t install it, it returns to me always error.

Do you get any errors in the logs? Or does the mail just not get sent?

BTW, to avoid duplicating the code in each template/controller, I’d actually put the logic into the form snippet (without the function wrapper).

The mail just not get sent.

I only need the form on homepage, I try to create the contact page only for test…

Could you try with a slash before #form.

<form action="<?php echo $page->url()?>/#form" method="post">

Another thing: When you send the form, does the send button get disabled? Or do you get a browser message when refreshing the page after clicking on the send button?

it works… I’m crying

May I ask what the difficulties were with version 3.0? It shouldn’t be harder to use than v2.3.

The 2.3 version had a simple one page guide on github to install and configure. Only controller, template form and little else.

For install the 3.0.1 there is 5 page of documentation to read, there aren’t simple example to copy or a linear guide and (I now I’m ignorant) I don’t know what is the Guards and how to configure it.

I promise that I try the 3.0.1 in the weekend, but I’m only a poor frontend developer, a day maybe…

Thanks for the feedback! I try to improve Uniform where I can and my goal for v3.0 definitely was not to make it harder to use.

The “Installation”, “Setup” and “Quick example” sections of the GitHub readme should get you up and running already. Do you have suggestions how to improve the readme for a quick start?

The Usage section of the documentation should be the one page guide you are looking for. Please get back to me if you think it can be improved. All other pages of the documentation (Methods, Guards, Actions etc.) are for advanced usage and reference only. You shouldn’t have to read them to get started with Uniform :wink:

I too have this problem. I have a form and the logic in the site footer (snippet) and it works great on all the subpages but not on the home page. The form action looks like this

action="<?php echo $page->url()?>/#main-footer"

I have tried to add and remove the “/” before #main-footer but still the same problem.
In Chrome Dev Tool I can see that Request Headers looks like this:

:authority: domain.com
:method: POST
:path: /
origin: https://domain.com
referer: https://domain.com/

From a subpage it looks like this:

referer: https://domain.com/products

No “/” at the end of the url. Is this the problem? If, yes, how do I fix this? I want the urls to end without a “/”.

Please help…