My uniform submit button doesn't work, please help me find out why

Hi, first mind you, that I’m quite a beginner at PHP and started to work seriously with PHP since I found out about kirby :blush: Kudos to Bastian :smile: so bear with my noobiness.

I would like to know what possibly go wrong in my uniform installation

I’ve already follow the step by step inspiration from enter link description here

Here are my codes,

Controller (contact.php)

<?php

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

   $form = uniform('contact-form', array(
         'required' => array('_name'  => 'name','_from' => 'email'),
         'actions'  => array(
            array(
               '_action' => 'email',
               'to'      => '(string) $site->email()',
               'sender'  => 'info@topmodelagency.co.id',
               'subject' => $site->title()->html() . ' - message from the contact form'
            )
         )
      )
   );

   return compact('form');
};

Template (contact.php)

<?php snippet('header2') ?>
<?php snippet('form') ?>
<?php snippet('footer') ?>

Snippets for the form (form.php)

    <!-- ========== CONTACT START ========== -->

    <section id="contact">
        <div class="parallax" data-velocity=".4" data-fit="-800" style="background-color: #181818;"></div>
        <div class="tint"></div>
        <div class="container">
            <div class="row">
                <div class="col-md-12 text-center">
                    <h2>STAY IN TOUCH</h2>
                    <h4>DON'T HESITATE TO CONTACT US</h4>
                    <div class="divider"><i class="fa fa-envelope"></i></div>
                </div>
            </div>
            <form action="<?php echo $page->url()?>$form" method="post">
                <div >
                    <div class="col-md-4 text-center" >
                        <input<?php e($form->hasError('_name'), ' class="erroneous"')?> type="text" name="_name" id="name" class="form-control" value="<?php $form->echoValue('_name') ?>" placeholder="Name" required/>
                    </div>
                    <div class="col-md-4 text-center">
                        <input<?php e($form->hasError('_from'), ' class="erroneous"')?> type="email" class="form-control" name="_from" id="email" value="<?php $form->echoValue('_from') ?>" placeholder="Email" required/>
                    </div>
                    <div class="col-md-4 text-center" >
                        <input <?php e($form->hasError('subject'), ' class="erroneous"')?> type="text" class="form-control" name="subject" id="subject" value="<?php $form->echoValue('subject') ?>" placeholder="Subject" required/>
                    </div>
                    <input type="text" name="website" id="website" class="uniform__potty" />
                </div>
                <div >
                    <div class="col-md-12 text-center" >
                        <textarea class="form-control" rows="6" placeholder="Message" name="message" id="message"><?php $form->echoValue('message') ?></textarea>
                        <?php if ($form->hasMessage()): ?>
                          <div class="message <?php e($form->successful(), 'success' , 'error')?>">
                            <?php $form->echoMessage() ?>
                          </div>
                        <?php endif; ?>
                    </div>
                </div>
                <div>
                    <div class="col-md-12 text-center">
                        <button type="submit" name="_submit" value="<?php echo $form->token() ?>"class="btn2 btn-lg"<?php e($form->successful(), "disabled")?>>SUBMIT</button>
                    </div>
                </div>
            </form>
        </div>
    </section>

    <!-- ========== CONTACT END ========== -->

I used a modified one-pager themes for the templates. (If it helps)
I already have the same kind of controller config on other website I finished and it works. (it is not based on a theme, and is not a one pager)

What could possibly wrong in my installation?

Is nothing happening or do you get a message but no mail?
Do you have Kirby running locally or on a server?

Hi, SirNovi.

There is nothing happening.

I run it on a server:

a shared hosting configured with cpanel, I’ve tried to also create an email account on the server but there is still nothing happen.

here is the link to the website contact page if you want to check what I mean.

contact page

Hi @Absolem, there are two problems I see at first glance:

  1. 'required' => array('_name' => 'name','_from' => 'email')
    There is no name validator function. You can find all available validator functions here. You most probably want to allow any name and only check if it is present, so you can do this: '_name' => ''.
  2. 'to' => '(string) $site->email()'
    With the surrounding ' the text “(string) $site->email()” won’t resolve to the content of the email field of the site but will be taken literally. So you attempt to send an email to the address “(string) $site->email()” which isn’t a valid email address and will fail. Remove the ' and the email address will be correctly resolved: 'to' => (string) $site->email().

Please let me know if the form still doesn’t work.

Hi I’m sorry for the late reply.

The form has been working well, I found out that the problem is on the themes javascript.

And thank you @mzur your answer helps me with the follow up problems, I did use a wrong validator.

Kudos for kirby and the community building this